#include
using namespace std;
typedef long long ll;
struct Point {
int x, y;
Point() {}
Point(int x, int y) : x (x), y (y) {}
Point operator - (const Point &r) const {
return Point (x - r.x, y - r.y);
}
bool operator <(const Point &r) const {
return x max (b1.x, b2.x) ||
min (a1.y, a2.y) > max (b1.y, b2.y) ||
min (b1.x, b2.x) > max (a1.x, a2.x) ||
min (b1.y, b2.y) > max (a1.y, a2.y)) return false;
int c1 = (a1 - a2) ^ (a1 - b1);
int c2 = (a1 - a2) ^ (a1 - b2);
int c3 = (b1 - b2) ^ (b1 - a1);
int c4 = (b1 - b2) ^ (b1 - a2);
return 1ll * c1 * c2 <= 0 && 1ll * c3 * c4 <= 0;
}
int s, r, w, p;
Point p1[15], p2[15];
set S;
int squ(int x) {
return x * x;
}
int get_dis2(Point a, Point b) {
return squ (a.x - b.x) + squ (a.y - b.y);
}
bool find_senor(Point a, Point b) {
if (S.find (b) != S.end ()) {
int d2 = get_dis2 (a, b);
if (d2 > squ (r)) return false;
int cnt = 0;
for (int i=1; i<=w; ++i) {
//if (can_seg_seg_inter (a, b, p1[i], p2[i])) cnt++;
if (check (a, b, p1[i], p2[i])) cnt++;
}
if (cnt > r) return false;
return d2 <= squ (r - cnt);
}
else return false;
}
void run(Point a, vector &vec) {
for (int i=-r; i<=r; ++i) {
int d = sqrt (squ (r) - squ (i));
for (int j=-r; j<=r; ++j) {
Point b = Point (a.x + i, a.y + j);
if (find_senor (a, b)) vec.push_back (b);
}
}
}
int main(void) {
int T; scanf ("%d", &T);
while (T--) {
scanf ("%d%d%d%d", &s, &r, &w, &p);
S.clear ();
for (int i=1; i<=s; ++i) {
S.insert (read_point ());
}
for (int i=1; i<=w; ++i) {
p1[i] = read_point ();
p2[i] = read_point ();
}
vector vec;
for (int i=1; i<=p; ++i) {
Point a = read_point ();
vec.clear ();
run (a, vec);
sort (vec.begin (), vec.end ());
printf ("%d", vec.size ());
for (int i=0; i