import java.util.*; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String sa, sb, pa, pb, xa, xb; sa = in.next(); pa = in.next(); xa = in.next(); sb = in.next(); pb = in.next(); xb = in.next(); if(pa.length() > pb.length()) { System.out.println(sa); } else if(pb.length() > pa.length()) { System.out.println(sb); } else { int t = pa.compareTo(pb); if(t > 0) System.out.println(sa); else if(t < 0) System.out.println(sb); else System.out.println(-1); } } }