#include <stdio.h>
int main(void)
{
  int x,y,w,h,n;
  int limx,limy;
  int cx,cy;
  int i,j;
  int data;

  scanf("%d",&data);
  for(i=data;i>0;i--){
    
    int f=0;

    scanf("%d %d %d %d",&x,&y,&w,&h);
    scanf("%d",&n);
    limx=x+w;
    limy=y+h;

    for(j=0;j<n;j++){
      scanf("%d %d",&cx,&cy);
      if(x<=cx && cx<=limx && y<=cy && cy<=limy)
	f++;
    }

    printf("%d\n",f);
  }

  return 0;
}