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

using namespace std;

class doll{
public:

	doll(int a, int b){
		h = a;
		r = b;
	}

	int h;
	int r;

	bool operator<(doll arg){
		if(h < arg.h && r < arg.r){
			return true;
		}else{
			return false;
		}
	}
};

int main(void){
	int n;
	while(cin >> n && n){
		vector<doll> a,b,c;
		int h,r,ret;
		for(int i=0;i<n;i++){
			cin >> h >> r;
			a.push_back(doll(h,r));
		}
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> h >> r;
			b.push_back(doll(h,r));
		}
		vector<doll>::iterator it,jt;
		bool isused[b.size()];
		memset(isused,false,sizeof(isused));
		ret = a.size();
		for(it=a.begin();it!=a.end();++it){
			jt = it;
			++jt;
			for(int pos=0;(unsigned int)pos<b.size();pos++){
				if(isused[pos]) continue;
				if(jt == a.end()){
					if(*it < b[pos]){
						isused[pos] = true;
						ret++;
					}
				}else{
					if(*it < b[pos] && b[pos] < *jt){
						isused[pos] = true;
						ret++;
					}
				}
			}
		}
		cout << ret << endl;
	}
}