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

pair<int,int> D[220];

int N, M, h, r;

int main() {

	while ( cin >> N && N ) {

		for ( int i = 0; i < N; i++) {

			cin >> h >> r;
			D[i] = make_pair(h, r);

		}

		cin >> M;

		for ( int i = 0; i < M; i++) {

			cin >> h >> r;
			D[N+i] = make_pair(h, r);

		}

		sort(D,D+N+M);

		int A[200];
		
		A[0] = 0;

		for ( int i = 0; i < N + M; i++) {

			int maxaj = 0;
			
			for ( int j = 0; D[j].first < D[i].first; j++ ) {
			
				if ( D[j].second < D[i].second ) {
				
					maxaj = max( maxaj, A[j] );
				
				}
			
			}
			
			A[i] = 1 + maxaj;

		}
		
		int maxai = 0;

		for ( int i = 0; i < N + M; i++) {
			
			maxai = max( maxai, A[i] );
				
		}
		
		cout << maxai << endl;

	}

}