#include <stdio.h>
int main(void)
{
	int X,Y,W,H,N;
	int n,i,j,x,y;
	int count;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		count=0;
		scanf("%d%d%d%d",&X,&Y,&W,&H);
		scanf("%d",&N);
		for(j=0;j<N;j++){
		scanf("%d%d",&x,&y);
		if((x>=X)&&(x<=(X+W))&&(y>=Y)&&(y<=Y+H))
		count++;
		}
		printf("%d\n",count);
	}
	return 0 ;
}