import java.util.*; import java.math.*; public class Janken{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); String s1 = scan.next(); BigInteger p1 = new BigInteger(scan.next()); String x1 = scan.next(); String s2 = scan.next(); BigInteger p2 = new BigInteger(scan.next()); String x2 = scan.next(); int d = -1; System.out.println((p1.compareTo(p2) > 0)?s1:(p1.compareTo(p2) == 0)?d:s2); } }