# Stack: LIFO data structure

S = [None]*100
sp = 0

def is_empty():
    global sp
    return sp == 0

def push(x):
    global sp, S
    if sp < len(S):
        S[sp] = x
        sp = sp + 1
    else:
        raise Exception('stack overflow!')

def pop():
    global sp, S
    if sp > 0:
        sp = sp - 1
        return S[sp]
    else:
        raise Exception('stack underflow!')
