const max=500;
      eps=0.000001;
var P,Q,xsa,ysa,xsb,ysb:Integer;
    H:array[0..max+1,0..max+1] of Integer;
    Good,Byl,Licz:array[0..max+1,0..max+1] of Boolean;
    Daleko:array[0..max+1,0..max+1] of Integer;


procedure Wczyt;
var i,j:Integer;
begin
  Readln(P,Q);
  for i:=1 to P do begin
    for j:=1 to Q do Read(H[i,j]);
    readln;
  end;
  Readln(xsa,ysa,xsb,ysb);
end;

function Jest(a,b,c,d:Integer):Boolean;
var i,j,st,kon:Integer;
    x1,x2,y1,y2,z1,z2,t,xt,yt,zt:Extended;
begin
  x1:=a+0.5;
  y1:=b+0.5;
  z1:=H[a,b]+0.5;
  x2:=c+0.5;
  y2:=d+0.5;
  z2:=H[c,d]+0.5;
  if a<=c then begin
    st:=a+1;
    kon:=c;
  end
  else begin
    st:=c+1;
    kon:=a
  end;
  for i:=st to kon do begin
    t:=(i-x1)/(x2-x1);
    yt:=(y2-y1)*t+y1;
    zt:=(z2-z1)*t+z1+eps;
    if Abs(Round(yt)-yt)<eps then begin
      j:=Round(yt);
      if (i-x1)*(j-y1)>0 then begin
        if (H[i,j]>=zt) or (H[i-1,j-1]>=zt) then begin
	  Jest:=False;
	  Exit;
	end;
      end
      else begin
        if (H[i,j-1]>=zt) or (H[i-1,j]>=zt) then begin
	  Jest:=False;
	  Exit;
	end;      
      end;
    end
    else begin
      j:=Round(Int(yt));
      if (H[i,j]>=zt) or (H[i-1,j]>=zt) then begin
        Jest:=False;
	Exit;
      end;
    end;
  end;
  {@@@@@@@@@@@@@@@@@@@@@2}
  if b<=d then begin
    st:=b+1;
    kon:=d;
  end
  else begin
    st:=d+1;
    kon:=b
  end;
  for j:=st to kon do begin
    t:=(j-y1)/(y2-y1);
    xt:=(x2-x1)*t+x1;
    zt:=(z2-z1)*t+z1+eps;
    if Abs(Round(xt)-xt)<eps then begin
      i:=Round(xt);
      if (i-x1)*(j-y1)>0 then begin
        if (H[i,j]>=zt) or (H[i-1,j-1]>=zt) then begin
	  Jest:=False;
	  Exit;
	end;
      end
      else begin
        if (H[i,j-1]>=zt) or (H[i-1,j]>=zt) then begin
	  Jest:=False;
	  Exit;
	end;      
      end;
    end
    else begin
      i:=Round(Int(xt));
      if (H[i,j]>=zt) or (H[i,j-1]>=zt) then begin
        Jest:=False;
	Exit;
      end;
    end;
  end;
  Jest:=True;
end;

function OK(a,b:Integer):Boolean;
begin
  if (a<0) or (a>P) or (b<0) or (b>Q) then Ok:=False
  else begin
    if not Licz[a,b] then begin
      Licz[a,b]:=True;
      Good[a,b]:=Jest(a,b,xsa,ysa) or Jest(a,b,xsb,ysb);
    end;
    Ok:=(not Byl[a,b]) and Good[a,b];
  end;
end;

var Kol:array[1..max*max,0..1] of Integer;
    pk,kk:Integer;

procedure Wstaw(a,b:Integer);
begin
  Kol[kk,0]:=a;
  Kol[kk,1]:=b;
  Inc(kk);
end;

procedure Wez(var a,b:Integer);
begin
  a:=Kol[pk,0];
  b:=Kol[pk,1];
  Inc(pk);
end;

procedure Idz(stx,sty,tx,ty:Integer);
var x,y,wys,odl:Integer;
begin
  FillChar(Daleko,Sizeof(Daleko),$7F);
  FillChar(Byl,Sizeof(Byl),0);  
  Daleko[stx,sty]:=0;
  Byl[stx,sty]:=True;
  Kol[1,0]:=stx;
  Kol[1,1]:=sty;
  pk:=1;
  kk:=2;
  repeat
    Wez(x,y);
    wys:=H[x,y];
    odl:=Daleko[x,y];
    if Ok(x,y+1) and (H[x,y+1]<=wys+1) and (H[x,y+1]>=wys-3)then begin
      Wstaw(x,y+1);
      Byl[x,y+1]:=True;
      Daleko[x,y+1]:=odl+1;
    end;
    if Ok(x,y-1) and (H[x,y-1]<=wys+1) and (H[x,y-1]>=wys-3)then begin
      Wstaw(x,y-1);
      Byl[x,y-1]:=True;
      Daleko[x,y-1]:=odl+1;
    end;
    if Ok(x+1,y) and (H[x+1,y]<=wys+1) and (H[x+1,y]>=wys-3)then begin
      Wstaw(x+1,y);
      Byl[x+1,y]:=True;
      Daleko[x+1,y]:=odl+1;
    end;
    if Ok(x-1,y) and (H[x-1,y]<=wys+1) and (H[x-1,y]>=wys-3)then begin
      Wstaw(x-1,y);
      Byl[x-1,y]:=True;
      Daleko[x-1,y]:=odl+1;
    end;    
    if Byl[tx,ty] then Break;
  until pk=kk;
end;

const nie=1000000;    
var k,min:Integer;    
begin
  Readln(k);
  while k>0 do begin
    Wczyt;
   Dec(k);
{    min:=nie;
    
    FillChar(Licz,Sizeof(Licz),0);
    Idz(xsa,ysa,xsb,ysb);
    if Byl[xsb,ysb] then min:=Daleko[xsb,ysb];

    Idz(xsb,ysb,xsa,ysa);
    if (Byl[xsa,ysa]) and (Daleko[xsa,ysa]<min)
      then min:=Daleko[xsa,ysa];    
    if min<>nie then Writeln('The shortest path is ',min,' steps long.')
    else Writeln('Mission impossible!');
 } end;
end.