class Node(object):
    def __init__(self,value):
        self.value=value
        self.next=None


class stack(object):
    def __init__(self):
        self.top=None

    def peek(self):
        if self.top!=None:
            return self.top.value
        else:
            return None
    def push(self,value):
        node=Node(value)
        node.next=self.top
        self.top=node
        return node.value

    def pop(self):
        if self.top==None:
            return None
        else:
            tmp=self.top.value
            self.top=self.top.next
            return tmp

if __name__ =='__main__':
    s=stack()
    s.push(1)
    s.push(2)
    s.push(3)

    print(s.pop())
    print(s.pop())
    print(s.pop())