#include #include #include #include #include #include #include #include #define REP(i,k,n) for(int i=k;i P; int main() { string sa,sb,pa,pb,xa,xb; cin >> sa >> pa >> xa; cin >> sb >> pb >> xb; while(pa.size() > 1 && pa[0]) { pa = pa.substr(1,pa.size()-1); } while(pb.size() > 1 && pb[0]) { pb = pb.substr(1,pb.size()-1); } if(pa == pb) cout << -1 << endl; else if(pa > pb) cout << sa << endl; else cout << sb << endl; return 0; }