#include <bits/stdc++.h>
using namespace std;
struct n{
int x,y;
}p[197];
int a[15][15],n,m,x1,y3,x2,y2;
bool f[15][15];
void dfs(int x,int y,int step){
if (x < 1 || x > n || y < 1 || y > m || f[x][y] || a[x][y] == 0) return;
p[step].x = x;
p[step].y = y;
f[x][y] = 1;
if (x == x2 && y == y2){
for (int i = 1; i <= step; i++){
cout << '(' << p[i].x << ',' << p[i].y << ')';
if (i < step) cout << "->";
}
cout << "\n";
p[step].x = 0;
p[step].y = 0;
f[x][y] = 0;
return;
}
dfs(x,y - 1,step + 1);
dfs(x - 1,y,step + 1);
dfs(x,y + 1,step + 1);
dfs(x + 1,y,step + 1);
p[step].x = 0;
p[step].y = 0;
f[x][y] = 0;
}
int main(){
cin >> n >> m;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
cin >> x1 >> y3;
cin >> x2 >> y2;
dfs(x1,y3,1);
return 0;
}