#35908: answer


1452945-9@g.puiching.edu.mo (sandy koya)


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