#include "bits/stdc++.h" #include #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define rrep(i, n) for(ll i=(n)-1; i >=0; i--) #define ALL(v) v.begin(),v.end() #define rALL(v) v.rbegin(),v.rend() #define FOR(i, j, k) for(ll i=j;i llvec; typedef std::vector dvec; typedef pair P; typedef long double ld; struct edge{ll x, c;}; /************************************** ** A main function starts from here ** ***************************************/ int main(){ ll R, C, T; cin >> R >> C >> T; matrix A(R*C, R*C); matrix e(R*C, R*C); rep(i, R*C)e(i, i) = 1.0; P s, g; cin >> s.fi >> s.se; cin >> g.fi >> g.se; std::vector B(R); rep(i, R)cin >> B[i]; auto ind = [R, C](ll i, ll j){return i*C + j;}; rep(i, R){ rep(j, C){ ll cnt = 0; if(B[i][j]!='#'){ if(i-1>0 and B[i-1][j]!='#')cnt++; if(i+10 and B[i][j-1]!='#')cnt++; if(j+10 and B[i-1][j]!='#')A(ind(i, j), ind(i-1, j))+=1./cnt; if(i+10 and B[i][j-1]!='#')A(ind(i, j), ind(i, j-1))+=1./cnt; if(j+10){ if(T%2==1){ e = prod(A, e); } A = prod(A,A); T/=2; } //s.fi--;s.se--; //g.fi--;g.se--; cout << e(ind(s.fi, s.se), ind(g.fi, g.se))<