#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
int main()
{
	cin>>n;
	vector<int>a(n);
	for(int&i:a)cin>>i;
	cin>>m;
	vector<int>b(m);
	for(int&i:b)cin>>i;
	cout<<lexicographical_compare(a.begin(),a.end(),b.begin(),b.end())<<endl;
}
