#include int r1,c1,r2,c2,rs,cs,re,ce; char s[4096]; int i,j,k; int maze[9][9]; int src[9][9]; char washere[9][9]; char card; int good; int search(int x, int y) { if (re==0 || re==8 || ce==0 || ce==8) return 0; if (washere[y][x]) return 0; if (x==ce && y==re) return 1; washere[y][x]=1; if (y>1 && ((src[y][x]&1)==1) && ((src[y-1][x]&4)==4)) { if (search(x,y-1)) return 1; } if (x<7 && ((src[y][x]&2)==2) && ((src[y][x+1]&8)==8)) { if (search(x+1,y)) return 1; } if (y<7 && ((src[y][x]&4)==4) && ((src[y+1][x]&1)==1)) { if (search(x,y+1)) return 1; } if (x>1 && ((src[y][x]&8)==8) && ((src[y][x-1]&2)==2)) { if (search(x-1,y)) return 1; } return 0; } int tryxp(int row) { int i; memset(washere,0,sizeof(washere)); memcpy(src,maze,sizeof(src)); for (i=7;i>=2;i--) src[row][i]=src[row][i-1]; src[row][1]=card; cs=c1; rs=r1; ce=c2; re=r2; if (re==row) ce++; if (rs==row) { cs++; if (cs==8) cs=1; } return search(rs,cs); } int tryxn(int row) { int i; memset(washere,0,sizeof(washere)); memcpy(src,maze,sizeof(src)); for (i=1;i<=6;i++) src[row][i]=src[row][i+1]; src[row][7]=card; cs=c1; rs=r1; ce=c2; re=r2; if (re==row) ce--; if (rs==row) { cs--; if (cs==0) cs=7; } return search(rs,cs); } int tryyp(int col) { int i; memset(washere,0,sizeof(washere)); memcpy(src,maze,sizeof(src)); for (i=7;i>=2;i--) src[i][col]=src[i-1][col]; src[1][col]=card; cs=c1; rs=r1; ce=c2; re=r2; if (ce==col) re++; if (cs==col) { rs++; if (rs==8) rs=1; } return search(rs,cs); } int tryyn(int col) { int i; memset(washere,0,sizeof(washere)); memcpy(src,maze,sizeof(src)); for (i=1;i<=6;i++) src[i][col]=src[i+1][col]; src[7][col]=card; cs=c1; rs=r1; ce=c2; re=r2; if (ce==col) re--; if (cs==col) { rs--; if (rs==0) rs=7; } return search(rs,cs); } int try() { if (tryxp(2)) return 1; if (tryxp(4)) return 1; if (tryxp(6)) return 1; if (tryxn(2)) return 1; if (tryxn(4)) return 1; if (tryxn(6)) return 1; if (tryyp(2)) return 1; if (tryyp(4)) return 1; if (tryyp(6)) return 1; if (tryyn(2)) return 1; if (tryyn(4)) return 1; if (tryyn(6)) return 1; return 0; } /* 1 = up, 2=right, 4=down, 8=left */ int main() { while(1) { memset(maze,0,sizeof(maze)); scanf("%d %d %d %d",&r1,&c1,&r2,&c2); if (r1==0 && r2==0 && c1==0 && c2==0) break; gets(s); gets(s); for (i=1;i<=7;i++) { gets(s); for (j=1;j<=7;j++) if (s[4*j-3]=='|') maze[i][j]|=1; gets(s); for (j=1;j<=7;j++) if (s[4*j-4]=='-') maze[i][j]|=8; for (j=1;j<=7;j++) if (s[4*j-2]=='-') maze[i][j]|=2; gets(s); for (j=1;j<=7;j++) if (s[4*j-3]=='|') maze[i][j]|=4; gets(s); } card=0; gets(s); if (s[1]=='|') card|=1; gets(s); if (s[0]=='-') card|=8; if (s[2]=='-') card|=2; gets(s); if (s[1]=='|') card|=4; gets(s); good=0; for (i=0;i<4;i++) { if (try()) { good=1; break; } card=(card>>1)|((card&1)<<3); } if (good) printf("You can win in one move.\n"); else printf("Bad luck!\n"); } return 0; }