#include using namespace std; int main (){ vector N(2); string R1,R2,P1,P2; cin >> N[0] >> R1 >> P2 >> N[1] >> R2 >> P2; cout << (R1==R2 ? "-1" : N[!(R1.size()>R2.size()||(R1.size()==R2.size()&&R1>R2))]) << endl; return 0; }