#include <iostream>
using namespace std;
typedef pair<int, int> P;

int main() {
    int c;
    cin >> c;
    while (c--) {
        int x, y, w, h;
        cin >> x >> y >> w >> h;
        int n;
        cin >> n;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int a, b;
            cin >> a >> b;
            if (x <= a && a <= x + w && y <= b && b <= y + h) {
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}