import java.io.*; import java.util.*; import java.math.*; class Main201 { public static void out (Object out) { System.out.println(out); } public static int comp (String s1, String s2) { int len1 = s1.length(); int len2 = s2.length(); if (len1 > len2) { return 1; } else if (len1 < len2) { return -1; } for (int i = 0; i < len1; i++) { int num1 = s1.charAt(i) - '0'; int num2 = s2.charAt(i) - '0'; if (num1 > num2) { return 1; } else if (num1 < num2) { return -1; } } return 0; } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line1 = br.readLine().split(" "); String[] line2 = br.readLine().split(" "); int c = comp(line1[1], line2[1]); System.out.println(c == 1 ? line1[0] : c == -1 ? line2[0] : -1); } }