| 记录编号 | 
        186093 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        1105.走迷宫 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         VacaTionGOD | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        Pascal | 
        运行时间 | 
        0.014 s  | 
    
    
        | 提交时间 | 
        2015-09-11 13:56:01 | 
        内存使用 | 
        0.13 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		const
 x1:array[1..4] of integer=(-1,0,0,1);
 y1:array[1..4] of integer=(0,-1,1,0);
 maxnm=15;
var
 n,m,x,y,i,j,maxm,maxn,xx,yy: byte;
 g,b:array[0..maxnm,0..maxnm] of 0..1;
 t:array[1..maxnm*maxnm,1..2] of integer;
 total:longint;
procedure print;
  var i:integer;
  begin
    write('(',t[1,1],',',t[1,2],')');
    for i:=2 to j do
      write('->(':2,t[i,1],',',t[i,2],')');
    writeln;
  end;
procedure sol(x,y:integer);
var i,xx,yy:integer;
begin
  for i:=1 to 4 do
    begin
      if (x+x1[i]>=1) and (x+x1[i]<=maxm) and (y+y1[i]>=1) and (y+y1[i]<=maxn)
and (g[x+x1[i],y+y1[i]]=1) and (b[x+x1[i],y+y1[i]]=0) then
        begin
          xx:=x+x1[i];yy:=y+y1[i];
          inc(j);
          t[j,1]:=xx; t[j,2]:=yy;
          b[xx,yy]:=1;
          if (xx=m) and (yy=n) then begin inc(total); print;end
          else sol(xx,yy);
          b[xx,yy]:=0;
          dec(j);
        end;
    end;
end;
begin
assign(input,'maize.in');
reset(input);
assign(output,'maize.out');
rewrite(output);
 readln(maxm,maxn);
 for i:=1 to maxm do
   begin
     for j:=1 to maxn do
       read(g[i,j]);
     readln;
   end;
 readln(x,y);
 readln(m,n);
 total:=0;j:=1;t[1,1]:=x;t[1,2]:=y;
 b[x,y]:=1;
 sol(x,y);
 if total=0 then writeln('-1');
 close(input);
 close(output);
end.