# -*- coding:utf-8 -*- if __name__ == "__main__": s1, p1, x1 = raw_input().split() s2, p2, x2 = raw_input().split() p1 = int(p1) p2 = int(p2) if p1 > p2: print s1 elif p1 < p2: print s2 else: print -1