a,b,c = input().split() d,e,f = input().split() if b==f: print(-1) else: print(a if b>f else d)