#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int n, m, a, b;
	vector<int> A;
	vector<int> B;
	cin >> n;
	rep(i, n)
	{
		cin >> a;
		A.push_back(a);
	}
	cin >> m;
	rep(i, m)
	{
		cin >> b;
		B.push_back(b);
	}
	
	rep(i, min(n, m))
	{
		if (A[i] > B[i])
		{
			cout << 0 << endl;
			exit(0);
		}
		else if (A[i] < B[i])
		{
			cout << 1 << endl;
			exit(0);
		}
	}
	if (n >= m)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 1 << endl;
	}
}
