#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  
  int N;
  while(cin >> N && N) {
    
    vector<pair<int, int> > v1, v2;
    
    for(int i=0; i<N; i++) {
      int h, r; cin >> h >> r;
      v1.push_back(make_pair(h, r));
      v2.push_back(make_pair(r, h));
    }

    int M; cin >> M;
    
    for(int i=0; i<M; i++) {
      int h, r; cin >> h >> r;
      v1.push_back(make_pair(h, r));
      v2.push_back(make_pair(r, h));
    }
    
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    
    int size = N+M;
    int dp1[size];
    int ans = 1;
    for(int i=0; i<size; i++) {
      dp1[i] = 1;
      for(int j=0; j<i; j++)
        if(v1[i].second > v1[j].second) { dp1[i] = max(dp1[i], dp1[j]+1); }
      ans = max(ans, dp1[i]);
    }
    
    int dp2[size];
    for(int i=0; i<size; i++) {
      dp2[i] = 1;
      for(int j=0; j<i; j++)
        if(v2[i].second > v2[j].second) { dp2[i] = max(dp2[i], dp2[j]+1); }
      ans = max(ans, dp2[i]);
    }
    
    cout << ans << endl;
    
  }
  
  return 0;
}