program christmas;
type
s=record
x,y:longint;
end;
var
i,j,k,l:longint;
n:longint;
a:array[1..500]of longint;
b:array[1..500]of boolean;
nan,nv:array[1..500]of s;
min:longint;
procedure search(x:longint);
var
i,j,k:longint;
begin
if x=n+1 then
begin
k:=0;
for i:=1 to n do
begin
j:=sqr(nan[i].x-nv[a[i]].x)+sqr(nan[i].y-nv[a[i]].y);
if j>k then k:=j;
end;
if k<min then
min:=k;
end
else
begin
for i:=1 to n do
if b[i]=false then
begin
a[x]:=i;
b[i]:=true;
search(x+1);
b[i]:=false;
a[x]:=0;
end;
end;
end;
begin
assign(input,'christmas.in');
reset(input);
assign(output,'christmas.out');
rewrite(output);
readln(n);
for i:=1 to n do
readln(nan[i].x,nan[i].y);
for i:=1 to n do
readln(nv[i].x,nv[i].y);
min:=99999999;
search(1);
writeln(min);
close(input);
close(output);
end.