#include <iostream>
#include <vector>
#include <algorithm>
#define F first
#define S second
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30;
int main(){
  int n, m;
  int dp[201], dp2[201];
  P doll[200];
  while(cin >> n && n){
    fill(doll, doll+200, P(0, 0));
    fill(dp, dp + 200, INF);
    for (int i = 0; i < n; i++){
      int a, b;
      cin >> a >> b;
      doll[i] = P(a, b);
    }
    cin >> m;
    for (int i = n; i < n + m; i++){
      int a, b;
      cin >> a >> b;
      doll[i] = P(a, b);
    }
    sort(doll, doll + n + m);
    dp[0] = doll[0].S;
    for (int i = 1; i < n + m; i++){
      int *p;
      p = lower_bound(dp, dp + 201, doll[i].S);
	if(doll[i].F != dp2[p-1-dp]){
	  *p = doll[i].S;
	  dp2[p-dp]=doll[i].F;
	}
    }
    cout << lower_bound(dp, dp + 201, INF) - dp << endl;
  }
  return 0;
}