na, pa, ja = input().split() nb, pb, jb = input().split() pa = int(pa) pb = int(pb) if pa > pb: print(na) elif pa < pb: print(nb) else: print(-1)