def judge(name1, point1, name2, point2): if len(point1) > len(point2): return name1 if len(point1) < len(point2): return name2 for i in range(0, len(point1)): if int(point1[i]) > int(point2[i]): return name1 if int(point1[i]) < int(point2[i]): return name2 return '-1' name1, point1, h = raw_input().split() name2, point2, h = raw_input().split() print judge(name1, point1, name2, point2)