#!/usr/bin/python3 # This problem is http://yukicoder.me/problems/436 first_line = input() second_line = input() point_A = first_line.split(' ')[1] point_B = second_line.split(' ')[1] if point_A == point_B: print(-1) elif point_A > point_B: print(first_line.split(' ')[0]) else: print(second_line.split(' ')[0])