#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int vy[4] = {-1,1,0,0}; int vx[4] = {0,0,-1,1}; int main(){ int R, C, T; cin >> R >> C >> T; int Sy, Sx, Gy, Gx; cin >> Sy >> Sx; cin >> Gy >> Gx; vector B(R); rep(i,R){ cin >> B[i]; } vector> prev(R,vector(C,0)), next(R,vector(C,0)); prev[Sy][Sx] = 1.0; rep(t,min(T,1000000 + T%2)){ /* cout << t << endl; rep(i,R){ rep(j,C){ cout << prev[i][j] << "\t"; } cout << endl; } cout << endl; */ rep(i,R) rep(j,C) next[i][j] = 0; rep(i,R) rep(j,C){ if(B[i][j] == '#') continue; int cnt = 0; rep(k,4){ int ny = i + vy[k]; int nx = j + vx[k]; if(B[ny][nx] == '.') cnt++; } if(cnt == 0){ next[i][j] = prev[i][j]; }else{ rep(k,4){ int ny = i + vy[k]; int nx = j + vx[k]; if(B[ny][nx] == '.') next[ny][nx] += 1.0 / cnt * prev[i][j]; } } } prev = next; } printf("%.12lf\n", prev[Gy][Gx]); return 0; }