#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    while(cin>>n,n!=0){
        int h[200],r[200];
        rep(i,n)cin>>r[i]>>h[i];
        int m;cin>>m;
        rep(i,m)cin>>r[n+i]>>h[n+i];
        vector<int>ord(n+m);
        rep(i,n+m)ord[i]=i;
        sort(ord.begin(),ord.end(),[&](int x,int y){return pint(r[x],-h[x])<pint(r[y],-h[y]);});
        int dp[222];
        rep(i,222)dp[i]=inf;
        dp[0]=0;
        for(auto i:ord){
            int idx=lower_bound(dp,dp+222,h[i])-dp;
            dp[idx]=h[i];
        }
        int ans=lower_bound(dp,dp+222,inf)-dp;
        cout<<ans-1<<endl;
    }
}
