program yaoyuandejuli;
var
t,k,i,j,n,m:longint;
max:int64;
ax,ay,bx,by:array[1..100000]of longint;
begin
assign (input,'faraway.in');
reset (input);
assign (output,'faraway.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 sqr(ax[i]-bx[j])+sqr(ay[i]-by[j])>max then
max:=sqr(ax[i]-bx[j])+sqr(ay[i]-by[j]);
writeln (extended(sqrt(max)):0:3);
end;
close (input);
close (output)
end.