class Node:
  def __init__(self, data, link):
    self.data = data
    self.link = link

class Stack:
  def __init__(self):
    self.top = 0
  def add(self, element):
    n = Node(element, self.top)
    self.top = n
  def hasMore(self):
    return self.top != 0
  def remove(self):
    aux = self.top
    self.top = aux.link
    return aux.data

s = Stack()
s.add("AA")
s.add(2)
s.add("BB")
s.add([1, 2, 3])
while s.hasMore():
  print str(s.remove())
