a = raw_input().split(" ") b = raw_input().split(" ") r = -1 pa = int(a[1]) pb = int(b[1]) if pa > pb: r = a[0] elif pa < pb: r = b[0] print r