#include<stdio.h>
int main(){
  int n,m,x,y,w,h,s,t,c;
  scanf("%d",&n);
  while(n--){
    scanf("%d %d %d %d",&x,&y,&w,&h);
    scanf("%d",&m);
    c=0;
    while(m--){
      scanf("%d %d",&s,&t);
      if(x<=s&&s<=x+w&&y<=t&&t<=y+h)c++;
    }
    printf("%d\n",c);
  }
  return 0;
}