a, b, c = gets.split; x, y, z = gets.split; b = b.to_i; y = y.to_i; puts b == y ? -1 : (b > y ? a : x);