#include< iostream>
#include< string>
#include< cstdio>
#include< stack>
#include< queue>
#include< map>
#include<stdlib.h>
#include < algorithm>
#include <math.h>
#include < vector>
using namespace std;
const int maxn=1000;
int A[maxn][maxn];
struct Node{
int x,y;
int step;
int h[maxn];
int z[maxn];
}node;
int n,m;
int X[4]={0,0,1,-1};
int Y[4]={1,-1,0,0};
bool inq[maxn][maxn]={false};
bool judge(int x,int y){
if(x>=n || x<0 || y>=m || y<0)return false;
if(A[x][y]==0 || inq[x][y]==true)return false;
return true;
}
Node s,e;
int BFS(Node s,Node e){
queueq;
node.x=s.x,node.y=s.y;
q.push(node);
inq[s.x][s.y]=true;
while(!q.empty()){
Node top=q.front();
q.pop();
if(top.x == e.x && top.y==e.y)
{
return top.step;
}
for(int i=0;i<4;i++){
int newx=top.x+X[i];
int newy=top.y+Y[i];
if(judge(newx,newy)){
node.x=newx,node.y=newy;
node.step=top.step+1;
node.h[node.step]=node.x;
node.z[node.step]=node.y;
q.push(node);
inq[newx][newy]=true;
}
}
}
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
scanf("%d",&A[i][j]);
}
}
scanf("%d%d%d%d",&s.x,&s.y,&e.x,&e.y);
node.step=0;
node.h[0]=s.x,node.z[0]=s.y;
int k=BFS(s,e);
printf("%d\n",k);
for(int i=0;i<k;i++){
printf("(%d,%d)->",node.h[i],node.z[i]);
}
printf("(%d,%d)\n",e.x,e.y);
return 0;
}
0代表障碍1代表出口