import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String Sa = scan.next(); String Pa = scan.next(); String Xa = scan.next(); String Sb = scan.next(); String Pb = scan.next(); String Xb = scan.next(); if(Xa.equals(Xb)) { } scan.close(); if(Pa.length() > Pb.length()) { System.out.println(Sa); }else if(Pa.length() < Pb.length()) { System.out.println(Sb); }else { for(int i = 0; i < Pa.length(); i++) { int a = Integer.parseInt(Pa.substring(i, i + 1)); int b = Integer.parseInt(Pb.substring(i, i + 1)); if(a > b) { System.out.println(Sa); System.exit(0); }else if(a < b) { System.out.println(Sb); System.exit(0); } } } System.out.println(-1); } }