#include <stdio.h>
int main(){
  int a, X, Y, W, H, N, x, y, j, i, b;
  scanf("%d", &a);
  for (j = 1;j <= a;j++){
    b=0;
  scanf("%d %d %d %d", &X, &Y, &W, &H);
  scanf("%d", &N);
  for (i = 1;i <= N;i++) {
    scanf("%d %d", &x, &y);
    if (X <= x && x <= X+W && Y <= y && y <= Y+H)b++;}
    printf("%d\n", b);
  }
  return 0;
}