/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] lines = br.readLine().split(" "); String aname = lines[0]; String apoint = lines[1]; lines = br.readLine().split(" "); String bname = lines[0]; String bpoint = lines[1]; if(apoint.equals(bpoint)){ System.out.println(-1); }else{ System.out.println(compare(apoint,bpoint)<0?bname:aname); } } public static int compare(String a,String b){ if(a.length() != b.length()){ return a.length() - b.length(); }else{ return a.compareTo(b); } } }