#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    cin >> n;
    vector<int> B(n);
    for (int i = 0; i < n; i++)
        cin >> B[i];
    if (lexicographical_compare(begin(A), end(A), begin(B), end(B)))
        cout << "1" << endl;
    else cout << "0" << endl;
}
