#include using namespace std; int main() { string s1, s2, p1, p2, x1, x2; cin >> s1 >> p1 >> x1 >> s2 >> p2 >> x2; if (p1 > p2) { cout << s1 << endl; } else if (p2 > p1) { cout << s2 << endl; } else { puts("-1"); } return 0; }