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

class LinkList(object):
    def __init__(self):
        self.head = Node(None)
        self.length = 0
    
    def is_empty(self):
        return self.length == 0
    
    def insert(self,item1,item2):
        cur = self.head
        node = Node(item2)
        while cur != None:
            if cur.data == item1:
                node.next = cur.next
                cur.next = node
            cur = cur.next
    
    def remove(self,item):
        cur = self.head
        pre = cur
        while cur != None:
            if cur.data == item:
                pre.next = cur.next
                break
            else:
                pre = cur
                cur = cur.next
            continue
    
    def travel(self):
        cur = self.head
        while cur != None:
            print(cur.data,end=" ")
            cur = cur.next
    
if __name__ == "__main__":
    while True:
        try:
            string=input()
            list=string.split(" ")
            ll = LinkList()
            ll.head.data = list[1]
            i=2
            while i<len(list)-1:
                item1 = list[i+1]
                item2 = list[i]
                ll.insert(list[i+1],list[i])
                i+=2
            ll.remove(list[len(list)-1])
            ll.travel()
        except:
            break