a = gets.chomp.split(" ") b = gets.chomp.split(" ") a[1] = a[1].to_i b[1] = b[1].to_i if(a[1] == b[1]) puts -1 else puts (a[1] > b[1])? a[0] : b[0] end