#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

typedef pair<int, int> doll;

int main()
{
	int n, m, i, j;
	vector<doll> vc;
	int dp[200];
	
	vc.reserve(200);
	
	while( cin >> n, n)
	{
		vc.clear();
		memset( dp, 0, sizeof(dp));
		
		for( i = 0; i < n; i++)
		{
			doll d;
			cin >> d.first >> d.second;
			vc.push_back(d);
		}
		
		cin >> m;
		
		for( i = 0; i < m; i++)
		{
			doll d;
			cin >> d.first >> d.second;
			vc.push_back(d);
		}
		
		sort(vc.begin(), vc.end());
		

		
		dp[0] = 1;
		doll surface(vc[0].first, vc[0].second);

		for( i = 1; i < n+m; i++)
		{
			if( surface.first < vc[i].first && surface.second < vc[i].second )
			{
				dp[i] = dp[i-1] + 1;
				surface.first = vc[i].first;
				surface.second = vc[i].second;
			}
			else
			{
				dp[i] = dp[i-1];
			}
		}
		
		
		cout << dp[n+m-1] << endl;
	}
	
	return 0;
}