#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a;
  string b,c,d;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b;
    c=c+b;
  }
  // cout<<"C "<<c<<"\n";
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b;
    d=d+b;
  }
  // cout<<"D "<<d<<"\n";
  if(c<d) cout<<"1\n";
  else cout<<"0\n";
}

