#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n;
  while(scanf("%d", &n) && n){
    vector<pair<int, int> >d;
    pair<int, int>t;
    int h, r;
    rep(i, n){
      scanf("%d %d", &h, &r);
      t = make_pair(h, r);
      d.push_back(t);
    }
    scanf("%d", &n);
    rep(i, n){
      scanf("%d%d", &h, &r);
      t = make_pair(h, r);
      d.push_back(t);
    }
    sort(d.begin(), d.end());

    rep(i, d.size()-1) if(d[i].first >= d[i+1].first || d[i].second >= d[i+1].second) d.erase(d.begin()+i+1);

    printf("%d\n", (int)d.size());
  }
  return 0;
}