ls2=[] while True: try: ls=list(input().split()) if ls[-1]=="0": if (ls[0] in ls2)==False: ls2.append(ls[0]) print(ls[0]) except: break