#include <bits/stdc++.h>
using namespace std;

int n,m,h,r;

int main(){
	while(scanf("%d",&n),n != 0){
		vector<pair<int,int> > v = vector<pair<int,int> >(n);
		for(int i = 0; i < n; i++){
			scanf("%d%d",&h,&r);
			v[i] = make_pair(h,r);
		}
		scanf("%d",&m);
		for(int i = 0; i < m; i++){
			scanf("%d%d",&h,&r);
			v.push_back(make_pair(h,r));
		}
		sort(v.begin(),v.end());
		if(n + m == 0){
			printf("0\n");
			continue;
		}
		int ans = 1;
		pair<int,int> p = v[0];
		for(int i = 1; i < n + m; i++){
			if(p.first < v[i].first && p.second < v[i].second){
				p = v[i];
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

