#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
const int N = 16;
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};
int a[N][N];
bool vis[N][N];
int n,m,sx,sy,ex,ey,k=1,tmp;
struct node{
int x,y;
}ans[N*N];
void pr(){
for(int i = 1; i < k-2 ;i++){
cout << "("<<ans[i].x << ","<< ans[i].y<< ")->";
}
cout << "("<< ans[k-1].x << ","<< ans[k-1].y<< ")" << endl;
tmp = 1;
return ;
}
void dfs(int x,int y){
if (x == ex && y == ey){
ans[k++] = {x,y};
pr();
return ;
}
for(int i = 0; i < 4; i++){
int newx = x + dx[i];
int newy = y + dy[i];
if (a[newx][newy] && !vis[newx][newy]){
vis[newx][newy] = 1;
ans[k++] = {newx,newy};
dfs(newx,newy);
k--;
vis[newx][newy] = 0;
}
}
}
int main(){
cin >> m >> n;
for(int i = 1; i <= m; i++){
for(int j = 1; j <= n; j++)
cin >> a[i][j];
}
cin >> sx >> sy >> ex >> ey;
ans[k++] = {sx,sy};
vis[sx][sy] = 1;
dfs(sx,sy);
if (tmp == 0) cout << -1;
return 0;
}