#include<iostream>
#include<queue>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> pii;

int main(){
	int m,n,h,r;
	vector<pii> mato;
	while(cin>>n,n){
		mato.clear();
		rep(i,n){cin>>h>>r;mato.push_back(pii(h,r));}
		cin>>m;
		rep(i,m){cin>>h>>r;mato.push_back(pii(h,r));}
		sort(mato.begin(),mato.end());
		pii now=mato[0];
		int cnt=1;
		loop(i,1,mato.size()){
			if(now.first<mato[i].first && now.second<mato[i].second){
				now=mato[i];
				cnt++;
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}