#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <cctype>
#include <queue>
#include <deque>
#include <ctime>
#include <cstring>
#include <string>
#define _e putchar (' ')
#define _v putchar ('\n')
#define ll long long
#define INF 999999999999999999ll
#define INE -999999999999999999ll
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;
inline int lowbit (int x) {
return x&(-x);
}
inline int mx(int x,int y) {
return x>y?x:y;
}
inline int mn(int x,int y) {
return x<y?x:y;
}
inline void r(int &x) {
int s=0,w=1;
char ch=getchar ();
while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar ();}
while(ch>='0'&&ch<='9') {s=(s<<1)+(s<<3)+(ch^48); ch=getchar ();}
x=s*w;
}
inline void wr(int x) {
if(x<0) x=-x,putchar (45);
if(x<10) {
putchar (x+48);
return ;
}
wr(x/10);
putchar (x%10+48);
}
inline int ab (int x) {
if(x<0) return -x;
return x;
}
inline void swap (int &x,int &y) {
x^=y^=x^=y;
}
const int N=1005;
int n,m,a,b,xx,yy,id,g[N][N],ansa[N],ansb[N];
bool flag[N][N],s;
int sx[4]={0,-1,0,1};
int sy[4]={-1,0,1,0};
inline void dfs (int x,int y) {
if(x==xx&&y==yy) {
for(int i=0;i<id;i++)
printf("(%d,%d)->",ansa[i],ansb[i]);
printf("(%d,%d)",ansa[id],ansb[id]),_v;
s=1;
return ;
}
for(int i=0;i<4;i++) {
int dx=x+sx[i],dy=y+sy[i];
if(dx<1||dy<1||dx>n||dy>m||flag[dx][dy]||g[dx][dy]==0) continue;
flag[dx][dy]=1;
ansa[++id]=dx;
ansb[id]=dy;
dfs (dx,dy);
flag[dx][dy]=0;
id--;
}
}
int main () {
r(n),r(m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
r(g[i][j]);
r(a),r(b),r(xx),r(yy);
ansa[0]=a;
ansb[0]=b;
dfs (a,b);
if(!s) wr(-1),_v;
return 0;
}