/*
  AOJ 2185
  Title:Petting Cats
  @kankichi573
*/
#include <stdio.h>
int in_area(int cx,int cy,int x,int y,int w,int h) 
{
  if((cx>=x)&&(cx<=x+w)&&(cy>=y)&&(cy<=y+h))
    return(1);
  else
    return(0);
}
main()
{
  int x,y,w,h,cx,cy;
  int m,n,i,j,cats;
  scanf("%d",&m);
  for(i=0;i<m;i++)
    {
      scanf("%d %d %d %d",&x,&y,&w,&h);
      scanf("%d",&n);
      
      cats=0;
      for(j=0;j<n;j++)
	{
	  scanf("%d %d",&cx,&cy);
	  if(in_area(cx,cy,x,y,w,h))
	     cats++;
	}
      printf("%d\n",cats);
    }
  return(0);
}