#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int, int> doll;

bool cmpr(const doll &a, const doll &b)
{
 	if( a.first == b.first )
		return a.second < b.second;
	else
		return a.first < b.first;
}

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(), cmpr);
		
		dp[0] = 1;
		int surface = 0;

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