program yaoyuandejuli;
var
t,k,i,j,n,m:longint;
max:real;
ax,ay,bx,by:array[1..100000]of longint;
begin
assign (input,'farawa.in');
reset (input);
assign (output,'farawa.out');
rewrite (output);
readln (t);
for k:=1 to t do
begin
readln (n,m);
for i:=1 to n do
readln(ax[i],ay[i]);
for i:=1 to m do
readln(bx[i],by[i]);
max:=0;
for i:=1 to n do
for j:=1 to m do
if sqrt(sqr(ax[i]-bx[j])+sqr(ay[i]-by[j]))>max then
max:=sqrt(sqr(ax[i]-bx[j])+sqr(ay[i]-by[j]));
writeln (max:0:3)
end;
close (input);
close (output)
end.