#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

int main() {
 UL N;scanf("%u",&N);
 int A[1000]; rep(i,N) scanf("%d",&A[i]);
 UL M;scanf("%u",&M);
 int B[1000]; rep(i,M) scanf("%d",&B[i]);
 UL ans=0;
 rep(i,min(M,N)){
  if(A[i]!=B[i]){ ans=((A[i]<B[i])?2:1); break; }
 }
 if(!ans) ans=((N<M)?2:1);
 printf("%u\n", ans-1);
 return 0;
}


