# -*- coding:utf-8 -*- if __name__ == '__main__': a, b = (input().split() for n in range(2)) sa, pa, xa = a[0], int(a[1]), a[2] sb, pb, xb = b[0], int(b[1]), b[2] s = "" print(-1 if pa == pb else sa if pa > pb else sb)