s1,p1,_ = raw_input().split() s2,p2,_ = raw_input().split() if p1 == p2: print -1 elif int(p1) > int(p2): print s1 else: print s2