#include<stdio.h>

int main(){
  int i, j, n, m, x, y, w, h, _x, _y, count;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d %d %d %d", &x, &y, &w, &h);
    scanf("%d", &m);

    for(j=0, count=0; j<m; j++){
      scanf("%d %d", &_x, &_y);
      if(_x >= x && _x <= x+w && _y >= y && _y <= y+h) count++;
    }
    printf("%d\n", count);
  }
  return 0;
}