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

#define pb push_back

struct MTR {
  int h, r;
};

int G[1000][1000];

MTR mtr[200];

int dfs(int s, int k, int N) {
  int ret = 0;
  
  bool last = true;
  for(int i=0; i<N; i++) {
    if(G[s][i]) {
      last = false;
      ret = max(ret, dfs(i, k+1, N));
    }
  }
  if(last) return k;
  
  return ret;
}

int main() {
  
  int n, m;
  while(cin >> n && n) {
    for(int i=0; i<n; i++) {
      cin >> mtr[i].h >> mtr[i].r;
    }
    
    cin >> m;
    for(int i=n; i<n+m; i++) {
      cin >> mtr[i].h >> mtr[i].r;
    }
    
    fill(G[0], G[1000], 0);
    
    int N = n+m;
    for(int i=0; i<N-1; i++) {
      for(int j=0; j<N; j++) {
	if(mtr[i].h < mtr[j].h && mtr[i].r < mtr[j].r) {
	  G[i][j] = 1;
	}
	if(mtr[j].h < mtr[i].h && mtr[j].r < mtr[i].r) {
	  G[j][i] = 1;
	}
      }
    }
    
    int ans = 0;
    
    for(int i=0; i<N; i++) {
      ans = max(ans, dfs(i, 1, N));
    }
    cout << ans << endl;
  }

  return 0;
}