#coding:utf-8 man_1=raw_input().split() man_2=raw_input().split() if man_1[1] < man_2[1]: print man_2[0] elif man_2[1] < man_1[1]: print man_1[0] else: print -1