import strutils, sequtils, algorithm, math import parseutils var aIn = readLine(stdin).split bIn = readLine(stdin).split a:tuple[name:string, point:string] b:tuple[name:string, point:string] a = (aIn[0], aIn[1]) b = (bIn[0], bIn[1]) if a.point == b.point: echo -1 elif max(a.point, b.point) == a.point: echo a.name else: echo b.name