#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
const int N=100;
int ans[N][N],n,m,fx,fy,lx,ly;
int bns[3][1000000];
bool temp[N][N];
int k=0;
int wax[5]={0,1,0,-1,0};
int way[5]={0,0,1,0,-1};
int pd;
void print(){
if(pd==0)pd=1;
for(int i=1;i<=k;i++)cout<<"("<<bns[1][i]<<","<<bns[2][i]<<")"<<"->";
cout<<"("<<lx<<","<<ly<<")"<<endl;
}
void dfs(int x,int y){
int xx,yy;
if(x==lx&&y==ly){
print();
return ;
}
else{
for(int i=1;i<=4;i++){
xx=x+wax[i];
yy=y+way[i];
if(ans[xx][yy]==1&&temp[xx][yy]==0){
temp[x][y]=1;
bns[1][k]=x;
bns[2][k]=y;
k++;
dfs(xx,yy);
temp[x][y]=0;
k--;}
}
}
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>ans[i][j];
}
}
cin>>fx>>fy;cin>>lx>>ly;
dfs(fx,fy);
if(pd==0)cout<<-1;
return 0;
}