// Aizu 2185: Petting Cats
// 2017.9.20 bal4u@uu

#include <stdio.h>

int main()
{
	int t, n, x, y, x1, y1, x2, y2, ans;

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &n);
		x2 += x1, y2 += y1;
		ans = 0; while (n-- > 0) {
			scanf("%d%d", &x, &y);
			if (x >= x1 && x <= x2 && y >= y1 && y <= y2) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}