#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<vector>
#include<string.h>
#include<map>
#include<cmath>
#include<queue>
#define ll long long
#define INF 0x7fffffff
#define MAX 0x3f3f3f3f
#define maxn 1000005
#define ull unsigned long long
using namespace std;
int t[105][105],n,m;
int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
struct node
{
int x,y,time;
friend operator < (node a, node b)
{
return a.time>b.time;
}
};
struct ff
{
int x,y;
char c;
};
ff f[105][105];
int bfs()
{
priority_queue<node> q;
node a,b;
a.x=n-1;
a.y=m-1;
if(f[n-1][m-1].c>='1'&&f[n-1][m-1].c<='9')
{
a.time=f[n-1][m-1].c-'0';
t[n-1][m-1]=a.time;
}
else a.time=0;
f[n-1][m-1].c='X';
q.push(a);
while(!q.empty())
{
a=q.top();
q.pop();
if(a.x==0&&a.y==0)
return a.time;
b=a;
int xx,yy;
for(int i=0;i<4;i++)
{
xx=b.x=a.x+dir[i][0];
yy=b.y=a.y+dir[i][1];
if(b.x>=0&&b.x<n&&b.y>=0&&b.y<m&&f[b.x][b.y].c!='X')
{
if(f[b.x][b.y].c>='1'&&f[b.x][b.y].c<='9')
{
t[b.x][b.y]=f[b.x][b.y].c-'0';
b.time=a.time+t[b.x][b.y]+1;
}
else
b.time=a.time+1;
q.push(b);
f[xx][yy].c='X';
f[xx][yy].x=a.x;
f[xx][yy].y=a.y;
}
}
}
return -1;
}
int main()
{
int i,j,num;
while(~scanf("%d%d",&n,&m))
{
getchar();
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
scanf("%c",&f[i][j].c);
getchar();
}
memset(t,0,sizeof(t));
num=bfs();
int em,u,v;
if(num!=-1)
{
printf("It takes %d seconds to reach the target position, let me show you the way.\n",num);
em=1;u=0;v=0;
while(em!=num+1)
{
printf("%ds:(%d,%d)->(%d,%d)\n",em++,u,v,f[u][v].x,f[u][v].y);
for(int h=0;h<t[f[u][v].x][f[u][v].y];h++)
printf("%ds:FIGHT AT (%d,%d)\n",em++,f[u][v].x,f[u][v].y);
int tmp1=f[u][v].x;
int tmp2=f[u][v].y;
u=tmp1;
v=tmp2;
}
}
else
printf("God please help our poor hero.\n");
printf("FINISH\n");
}
return 0;
}