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

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      vector<pair<int,int> > data;
      vector<pair<int,int> > sw;
      for(int i=0;i<n;i++)
	{
	  int h,r;
	  cin>>h>>r;
	  data.push_back(make_pair(h,r));
	  sw.push_back(make_pair(r,h));
	}
      int m;
      cin>>m;
      for(int i=0;i<m;i++)
	{
	  int h,r;
	  cin>>h>>r;
	  data.push_back(make_pair(h,r));
	  sw.push_back(make_pair(r,h));
	}
      sort(data.begin(),data.end(),greater<pair<int,int> >());
      sort(sw.begin(),sw.end(),greater<pair<int,int> >());

      pair<int,int> tmp[2]={data[0],sw[0]};
      int k[2]={1,1};
      for(int i=1;i<data.size();i++)
	{
	  if(tmp[0].first>data[i].first &&tmp[0].second>data[i].second)
	    {
	      k[0]++;
	      tmp[0]=data[i];
	    }
	  if(tmp[1].first>sw[i].first &&tmp[1].second>sw[i].second)
	    {
	      k[1]++;
	      tmp[1]=sw[i];
	    }
	}
      cout<<max(k[0],k[1])<<endl;
	/*
	  cout<<endl;
	  for(int i=0;i<data.size();i++)
	  cout<<data[i].first<<" "<<data[i].second<<endl;
	*/

    }

}