a = gets.split b = gets.split if a[1].to_i == b[1].to_i then puts "-1" elsif a[1].to_i > b[1].to_i then puts a[0] else puts b[0] end