import java.util.*; import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String sa = sc.next(); String pa = sc.next(); String xa = sc.next(); String sb = sc.next(); String pb = sc.next(); String xb = sc.next(); BigInteger num1 = new BigInteger(pa); BigInteger num2 = new BigInteger(pb); String ans = "-1"; if(num1.compareTo(num2) > 0) ans = sa; if(num1.compareTo(num2) < 0) ans = sb; System.out.println(ans); } }