Pagini recente » Cod sursa (job #1939714) | Cod sursa (job #88539) | Statistici Grigorosoaia Florin (Praetor) | Cod sursa (job #1233178) | Cod sursa (job #197974)
Cod sursa(job #197974)
var f,g:text;
c,x,y,s,l,n,k,a,b,q,aux,i,j:longint;
begin
assign(f,'gropi.in');reset(f);
assign(g,'gropi.out');rewrite(g);
readln(f,n,k);
for q:=1 to k do
readln(f,b,a);
readln(f,l);
for q:=1 to l do
begin
readln(f,x,y,i,j);
if y>j then begin
aux:=j;
j:=y;
y:=aux;
aux:=x;
x:=i;
i:=aux;
end;
c:=0;
if x=i then c:=1;
s:=(j-y+1)+1+(i-x)+1+c;
writeln(g,s);
end;
close(g);
end.