#include <stdio.h>

int main(void){
	int dsn,i,j;
	int x,y,w,h,n;
	int cx,cy,cc;
	scanf("%d",&dsn);
	for(i = 0; i < dsn; i++){
		cc = 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(
				x <= cx && cx <= x + w &&
				y <= cy && cy <= y + h
			){
				cc++;
			}	
		}
		printf("%d\n",cc);
	}

	return 0;
}