#include <cstring>
#include <iostream>
using namespace std;
int n;
int h[200], r[200];
int memo[200];

int solve(int x) {
	if (memo[x] != -1) return memo[x];
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (h[x] < h[i] && r[x] < r[i]) {
			res = max(res, solve(i));
		}
	}
	return memo[x] = (res + 1);
}

int main () {
	while (cin >> n, n) {
		memset(memo, -1, sizeof(memo));
		for (int i = 0; i < n; i++) {
			cin >> h[i] >> r[i];
		}
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> h[n + i] >> r[n + i];
		}
		n += m;
		int res = 0;
		for (int i = 0; i < n; i++) {
			res = max(res, solve(i));
		}
		cout << res << endl;
	}
	return 0;
}