#include using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(){ string sa, sb, pa, pb, xa, xb; cin >> sa >> pa >> xa >> sb >> pb >> xb; if (pa == pb) cout << -1 << endl; else if (pa.length() != pb.length()) cout << ( ( pa.length() > pb.length() ) ? sa : sb ); else cout << ( ( pa > pb ) ? sa : sb ); return 0; }