na, pa, ja = input().split() nb, pb, jb = input().split() ans = -1 if len(pa) > len(pb): ans = pa elif len(pa) < len(pb): ans = pb else: for i in range(len(pa)): if int(pa[i]) > int(pb[i]): ans = pa break elif int(pa[i]) < int(pb[i]): ans = pb break print(ans)