import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 3); String[] second = br.readLine().split(" ", 3); int winner = -1; char[] fArr = first[1].toCharArray(); char[] sArr = second[1].toCharArray(); if (fArr.length < sArr.length) { winner = 1; } else if (fArr.length > sArr.length) { winner = 0; } else { for (int i = 0; i < fArr.length; i++) { if (fArr[i] < sArr[i]) { winner = 1; break; } else if (fArr[i] > sArr[i]) { winner = 0; break; } } } if (winner == -1) { System.out.println(-1); } else if (winner == 0) { System.out.println(first[0]); } else { System.out.println(second[0]); } } }