#include <bits/stdc++.h>
using namespace std;
typedef __int128_t lll;
typedef pair<lll, lll> P;
#define x first
#define y second
// 叉乘
lll cross(P a, P b) {
return a.x * b.y - a.y * b.x;
}
// 点积
lll mul(P a, P b) {
return a.x * b.x + a.y * b.y;
}
// 点平方和
lll mul(P a) {
return a.x * a.x + a.y * a.y;
}
// 计算矢量
P del(P a, P b) {
return {a.x - b.x, a.y - b.y};
}
// 自定义的__int128输入函数
void read(lll &x) {
string s;
cin >> s;
x = 0;
bool neg = (s[0] == '-');
for (int i = neg; i < s.size(); ++i) {
x = x * 10 + (s[i] - '0');
}
if (neg) x = -x;
}
// 自定义的__int128输出函数
void write(lll x) {
if (x < 0) {
putchar('-');
x = -x;
}
string s;
do {
s += '0' + x % 10;
x /= 10;
} while (x > 0);
reverse(s.begin(), s.end());
for (char c : s) putchar(c);
}
void solve() {
int n;
read(n);
P C;
read(C.x);
read(C.y);
lll R;
read(R);
vector<P> a(n);
for (int i = 0; i < n; i++) {
read(a[i].x);
read(a[i].y);
}
lll ans = 0;
lll S = 0;
for (int l = 0, r = l + 1; l < n; l++) {
while (1) {
int rr = r % n + 1;
lll s = cross(del(a[rr], a[l]), del(C, a[l]));
if (s <= 0) break;
if (s * s < mul(del(a[rr], a[l])) * R * R) break;
S += cross(del(a[r], a[l]), del(a[rr], a[l]));
r = rr;
}
ans = max(ans, S);
int ll = l % n + 1;
S -= cross(del(a[r], a[l]), del(a[r], a[ll]));
}
write(ans);
putchar('\n');
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int _ = 1;
read(_);
while (_--) {
solve();
}
return 0;
}