#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	int t; cin >> t;
	rep(i, 0, t) {
		int X, Y, W, H; cin >> X >> Y >> W >> H;
		int N; cin >> N;
		int ans = 0;
		rep(i, 0, N) {
			int x, y; cin >> x >> y;
			if (X <= x&&x <= X + W&&Y <= y&&y <= Y + H)ans++;
		}
		cout << ans << endl;
	}
	return 0;
}