using static System.Console; class Simple { public static void Main(string[] args) { new Simple().Solve(); } string Sa, Pa, Xa; string Sb, Pb, Xb; int isAwin(string pa, string pb) { if (pa.Length != pb.Length) return pa.Length > pb.Length ? 1 : -1; for (var i = 0; i < pa.Length; ++i) if (pa[i] != pb[i]) return pa[i] > pb[i] ? 1 : -1; return 0; } void Solve() { var line1 = ReadLine().Split(); var line2 = ReadLine().Split(); Sa = line1[0]; Pa = line1[1]; Xa = line1[2]; Sb = line2[0]; Pb = line2[1]; Xb = line2[2]; var tmp = isAwin(Pa, Pb); var ans = tmp == 1 ? Sa : tmp == -1 ? Sb : "-1"; WriteLine(ans); } }