#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    int n, m;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    cin >> m;
    vector<int> b(m);
    for (int j = 0; j < m; ++j) cin >> b[j];
    if (n < m) {
        for (int i = 0; i < m - n; ++i) {
            a.emplace_back(0);
        }
    } else if (n > m) {
        for (int i = 0; i < n - m; ++i) {
            b.emplace_back(0);
        }
    }
    for (int k = 0; k < max(n, m); ++k) {
        if (a[k] < b[k]) {
            cout << 1 << endl;
            return 0;
        } else if (a[k] > b[k]) {
            cout << 0 << endl;
            return 0;
        }
    }
    if (n < m) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

