import java.util.Scanner; public class Yurufuwa{ public static void main(String arg[]){ String[] name = new String[2]; String[] point = new String[2]; String[] hand = new String[2]; int win = 0; Scanner sc = new Scanner(System.in); for(int i = 0;i<2;i++){ name[i] = sc.next(); point[i] = sc.next(); hand[i] = sc.next(); } if(point[0].length() > point[1].length()){ win = 1; }else if(point[0].length() < point[1].length()){ win = 2; }else{ for(int i = 0;i Character.getNumericValue(point[1].charAt(i))){ win = 1; break; }else if(Character.getNumericValue(point[0].charAt(i)) < Character.getNumericValue(point[1].charAt(i))){ win = 2; break; } } } if(win == 0){ System.out.println(-1); }else if(win == 1){ System.out.println(name[0]); }else{ System.out.println(name[1]); } } }