#include <stdio.h>

int main(void)
{
	int m, x, y, w, h, n, cx, cy, cat;
	int i, j;

	
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		cat = 0;
		scanf("%d%d%d%d", &x, &y, &w, &h);
		scanf("%d", &n);
		for (j = 0; j < n; j++) {
			scanf("%d%d", &cx, &cy);
			if (cx >= x && cx <= x + w)
				if (cy >= y && cy <= y + h)
					cat++;
		}
		printf("%d\n", cat);
	}
	
	return 0;
}

			