import java.io.*; // 処理 class Process { private String[] S; private String[] P; private String[] X; Process(String[] S, String[] P, String[] X) { this.S = S; this.P = P; this.X = X; } String getResult() { if(P[0].equals(P[1])) { return "-1"; } if(P[0].length() > P[1].length()) { return S[0]; } if(P[0].length() < P[1].length()) { return S[1]; } for(int i = 0; i < P[0].length(); i++) { if(P[0].charAt(i) > P[1].charAt(i)) { return S[0]; } if(P[0].charAt(i) < P[1].charAt(i)) { return S[1]; } } return ""; } } public class Main { public static void main(String[] args) throws IOException { var bufferedReader = new BufferedReader(new InputStreamReader(System.in)); var printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); // 入力 var S = new String[2]; var P = new String[2]; var X = new String[2]; for(int i = 0; i < 2; i++) { String[] input = bufferedReader.readLine().trim().split("[ ]+"); S[i] = input[0]; P[i] = input[1]; X[i] = input[2]; } // 出力 printWriter.println((new Process(S, P, X)).getResult()); bufferedReader.close(); printWriter.close(); } }