#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	int m;
	cin >> m;
	for (int z = 0; z < m; z++) {
		int x3, y3, w, h, x1, x2, y1, y2, n;
		cin >> x3 >> y3 >> w >> h;
		x1 = x3;
		y1 = y3 + h;
		x2 = x3 + w;
		y2 = y3;
		int sum = 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			if (x >= x1&&x <= x2&&y <= y1&&y >= y2)
				sum++;
		}
		cout << sum << endl;
	}
}