SA, PA, XA = input().split() SB, PB, XB = input().split() PA = int(PA) PB = int(PB) if PA == PB: print("-1") elif PA > PB: print(SA) else: print(SB)