#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int n, m;
	while(1){
		cin >> n;
		if(n == 0) break;
		vector<pair<int, int> > mato(200);
		for(int i = 0; i < n; i++){
			cin >> mato[i].first >> mato[i].second;
		}
		cin >> m;
		for(int i = 0; i < m; i++){
			cin >> mato[n + i].first >> mato[n + i].second;
		}
		sort(mato.begin(), mato.begin() + m + n);
		int cnt = 0;
		int maxh = 0, maxr = 0;
		for(int i = 0; i < n + m; i++){
			// cout << mato[i].first << " " << mato[i].second;
			if(mato[i].first > maxh && mato[i].second > maxr){
				cnt++;
				maxh = mato[i].first;
				maxr = mato[i].second;
			}
			// cout << " " << cnt << endl;
		}
		cout << cnt << endl;
	}
	return 0;
}