#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		int c, d, e, f,g;
		cin >> c >> d >> e >> f>>g;
		int s = 0;
		for (int h = 0; h < g; h++) {
			int i, j;
			scanf("%d%d", &i, &j);
			if (i >= c&&i <= c + e&&j >= d&&j <= d + f)s++;
		}
		cout << s << endl;
	}
}