#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)
#define COUNTER int i= 0,j = 0,k = 0,l = 0,m = 0, n= 0;
#define RETURN cout << endl;
/*vector<vector<int>>ArrayName = vector<vector<int>>(sizeofx, vector<int>(sizeofy, 0));*/
using namespace std;


int main() {
    int answer = 0;
    while (true) {
        /*pair??§????????§??±???*/
        vector< pair<int, int> > vp;
        int dp[205];
        int n; cin >> n; if (!n) break;
        for (int i = 0; i < n; i++) {
            int h, r; cin >> h >> r;
            vp.push_back(pair<int, int>(h, r));
        }
        int m; cin >> m;
        for (int i = 0; i < m; i++) {
            int h, r; cin >> h >> r;
            vp.push_back(pair<int, int>(h, r));
        }
        sort(vp.begin(), vp.end());
        //REP(i,vp.size()){cout << vp[i].first <<" " << vp[i].second<< endl;}
           int checkh = 0,checkr = 0;
        answer = 0;
        REP(i, m+n)
        {
            //dp???i?????????????????????????´???§??????????????????
            if(!i)
                answer++;
            else
                if(vp[i].first > checkr && vp[i].second >checkh)
                {
                    checkr = vp[i].first;
                    checkh = vp[i].second;
                    answer++;
                }
            
            
        }
        cout << answer << endl;
    }
}