#include<iostream>

using namespace std;

int main()
{
  int d;
  cin>>d;
  for(;d--;)
    {
      int x,y,w,h;
      cin>>x>>y>>w>>h;
      int n;
      cin>>n;
      int ans=0;
      for(;n--;)
	{
	  int xx,yy;
	  cin>>xx>>yy;
	  if(xx>=x &&
	     yy>=y &&
	     xx<=x+w &&
	     yy<=y+h)
	    ans++;
	}
      cout<<ans<<endl;
    }
}