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