#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n,m;
    
    cin >> n;
    
    int a[n];
    
    rep(i,0,n) cin >> a[i];
    
    cin >> m;
    int b[m];
    rep(i,0,m) cin >> b[i];
    
    
    rep(i,0,min(n,m)){
        if(a[i] > b[i]){
            cout << 0 << endl;
            return 0;
        }
        else if(a[i] < b[i]){
            cout << 1 << endl;
            return 0;
        }
    }
    
    if(n < m){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    
    return 0;
}
