#include<bits/stdc++.h>
using namespace std;
#define lpin(i,n,a) for(int i=0;i<n;i++)cin>>a[i];
int main(){
  int n,m,a[1000],b[1000];
  cin>>n;
  lpin(i,n,a);
  cin>>m;
  lpin(i,m,b);
  if(lexicographical_compare(a,a+n,b,b+m)){
    cout<<"1"<<endl;
  }
  else cout<<"0"<<endl;
  return 0;
}

