S1,P1,X1=raw_input().split() S2,P2,X2=raw_input().split() if int(P1)int(P2): print S1 else: print -1