#include #include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i, a, b) for(int i=(a);i<=(b);i++) #define RFOR(i, a, b) for(int i=(a);i>=(b);i--) #define MOD 1000000007 #define INF 1000000000 #define PI 3.14159265358979 using namespace std; typedef pair P; int main(void) { string sa, sb, xa, xb; string pa, pb; cin >> sa >> pa >> xa >> sb >> pb >> xb; if (pa.size() > pb.size()) { cout << sa << endl; }else if (pb.size() > pa.size()) { cout << sb << endl; }else if (pa > pb) { cout << sa << endl; } else if (pa < pb) { cout << sb << endl; } else { cout << -1 << endl; } return 0; }