program faraway;
const
filename='faraway';
maxn=100000;
var
t,n,m:longint;
ans:extended;
xa,xb,ya,yb:array[0..maxn] of longint;
procedure solve;
var
i,j,k:longint;
dis:extended;
begin
readln(t);
for k:=1 to t do
begin
readln(n,m);
dis:=0;
for i:=1 to n do readln(xa[i],ya[i]);
for i:=1 to m do readln(xb[i],yb[i]);
for i:=1 to n do
for j:=1 to m do
begin
dis:=sqrt((xa[i]-xb[j])*(xa[i]-xb[j])+(ya[i]-yb[j])*(ya[i]-yb[j]));
if dis>ans then ans:=dis;
end;
end;
end;
begin
assign(input,filename+'.in'); reset(input);
assign(output,filename+'.out'); rewrite(output);
solve;
writeln(ans:0:3);
close(input); close(output);
end.