#include<stdio.h>

int main(void){
	int tc,max;
	scanf("%d", &max);
	for(tc=0;tc<max;++tc){
		int i;
		int X,Y,W,H;
		int ncats;
		int insideCats = 0;

		scanf("%d%d%d%d", &X, &Y, &W, &H);
		scanf("%d", &ncats);

		for(i = 0; i < ncats; i++){
			int x, y;
			scanf("%d%d", &x, &y);
			if( (X <= x && x <= X + W) && (Y <= y && y <= Y + H) ){
				insideCats++;
			}
		}

		printf("%d\n", insideCats);
	}
	return 0;
}