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