#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const double delta = 0.996;
const double eps = 1e-15;
double X, Y;
struct Point {
double x, y;
} a[1005], ans;
int n;
double ans_val = 0;
double Min_Val(double x, double y) {
double res = X * X + Y * Y;
for (int i = 1; i <= n; i++) {
double dx = x - a[i].x;
double dy = y - a[i].y;
res = min(res, sqrt(dx * dx + dy * dy));
}
return res;
}
inline double Rand() {
return 2 * rand() - RAND_MAX;
}
inline void Solve() {
double T = 10000000;
while (T > eps) {
Point tmp = {ans.x + Rand() * T, ans.y + Rand() * T};
if (!(0 <= tmp.x && tmp.x <= X && 0 <= tmp.y && tmp.y <= Y)) {
T *= delta;
continue;
}
double tmp_val = Min_Val(tmp.x, tmp.y);
if (ans_val < tmp_val)ans = tmp, ans_val = tmp_val;
else if (exp((tmp_val - ans_val) / T) * RAND_MAX > rand())ans = tmp;
T *= delta;
}
}
signed main() {
// freopen("in", "r", stdin), freopen("out", "w", stdout);
int Ts;
scanf("%d", &Ts);
while (Ts--) {
scanf("%lf %lf %d", &X, &Y, &n);
ans = {0, 0};
for (int i = 1; i <= n; i++) {
scanf("%lf %lf", &a[i].x, &a[i].y);
ans.x += a[i].x, ans.y += a[i].y;
}
ans.x /= n, ans.y /= n;
ans_val = Min_Val(ans.x, ans.y);
for (int i = 1; i <= 10; i++)Solve();
printf("The safest point is (%.1lf, %.1lf).\n", ans.x, ans.y);
}
return 0;
}