import java.util.Scanner; public class yukicoder_201 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); String sa = stdIn.next(); long pa = stdIn.nextLong(); String xa = stdIn.next(); String sb = stdIn.next(); long pb = stdIn.nextLong(); String xb = stdIn.next(); if (pa > pb) { System.out.println(sa); } else if (pa == pb) { System.out.println(-1); } else { System.out.println(sb); } } }