#include <stdio.h>

int main(void)
{
	int dataset;
	int X, Y, W, H;
	int N;
	int x, y;
	int count;
	
	scanf("%d", &dataset);
	for (; dataset > 0; dataset--){
		scanf("%d%d%d%d", &X, &Y, &W, &H);
		
		scanf("%d", &N);
		count = 0;
		for (; N > 0; N--){
			scanf("%d%d", &x, &y);
			
			if ((X <= x && x <= X + W) &&
			    (Y <= y && y <= Y + H)){
					
				count++;
			}
		}
		printf("%d\n", count);
	}
	
	return (0);
}

			
	