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