#include int R,C; long long T; int sy, sx; int gy, gx; char board[12][12]; //sentinelを準備する。 double prob_board[12][12]; double prob_tmpboard[12][12]; char tmp[11]; int main(){ scanf("%d %d %lld",&R,&C,&T); scanf("%d %d",&sy,&sx); scanf("%d %d",&gy,&gx); for(int y = 1; y <= R; y++){ scanf("%s",tmp); for(int x = 1; x <= C; x++){ board[x][y] = (tmp[x-1] == '#')? 0:1; prob_board[x][y] = 0.0; } } for(int y = 0; y <= R+1; y++){ board[0][y] = board[R+1][y] = 0; prob_board[0][y] = prob_board[R+1][y] = 0.0; } for(int x = 0; x <= C+1; x++){ board[x][0] = board[x][C+1] = 0; prob_board[x][0] = prob_board[x][C+1] = 0.0; } /* for(int y = 1; y <= R; y++){ for(int x = 1; x <= C; x++){ printf("%d,", board[x][y]); } puts(""); } puts("-"); */ for(int x = 1; x <= C; x++){ for(int y = 1; y <= R ;y++){ int cnt = 0; if(board[x][y]==0) continue; if(board[x][y-1] != 0) cnt++; if(board[x][y+1] != 0) cnt++; if(board[x-1][y] != 0) cnt++; if(board[x+1][y] != 0) cnt++; board[x][y]=cnt; } } /* for(int y = 1; y <= R; y++){ for(int x = 1; x <= C; x++){ printf("%d,", board[x][y]); } puts(""); } */ prob_board[sx+1][sy+1] = 1.0; T = T % 100000; for(long long move = 1; move <= T; move++){ for(int x = 1; x <= C; x++){ for(int y = 1; y <= R; y++){ if(board[x][y] != 0){ prob_tmpboard[x][y] = 0.0; if(board[x-1][y]!=0) prob_tmpboard[x][y] += prob_board[x-1][y]/(double)board[x-1][y]; if(board[x+1][y]!=0) prob_tmpboard[x][y] += prob_board[x+1][y]/(double)board[x+1][y]; if(board[x][y-1]!=0) prob_tmpboard[x][y] += prob_board[x][y-1]/(double)board[x][y-1]; if(board[x][y+1]!=0) prob_tmpboard[x][y] += prob_board[x][y+1]/(double)board[x][y+1]; } } } // printf("move=%lld-------------------------------\n",move); for(int y = 1; y <= R; y++){ for(int x = 1; x <= C; x++){ prob_board[x][y] = prob_tmpboard[x][y]; // printf("%.3f ", prob_board[x][y]); } // puts(""); } } if(board[gx+1][gy+1] != 0){ printf("%.12f\n",prob_board[gx+1][gy+1]); }else{ if(sx==gx && sy==gy){ puts("1.0"); }else{ puts("0.0"); } } }