a = raw_input().split(" ") b = raw_input().split(" ") r = -1 if a[1] > b[1]: r = a[0] elif a[1] < b[1]: r = b[0] print r