import sys sys.setrecursionlimit(10 ** 6) def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def SI(): return sys.stdin.readline()[:-1] def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] int1 = lambda x: int(x) - 1 def MI1(): return map(int1, sys.stdin.readline().split()) def LI1(): return list(map(int1, sys.stdin.readline().split())) p2D = lambda x: print(*x, sep="\n") dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] import numpy as np def dot(aa,bb): return [[sum(a*b for a,b in zip(row,col)) for col in zip(*bb)] for row in aa] def solve(t): pp = [[0] * w for _ in range(h)] for i in range(h): for j in range(w): if aa[i][j]: continue for di, dj in dij: ni, nj = di + i, dj + j if ni < 0 or nj < 0 or ni >= h or nj >= w: continue pp[i][j] += 1 - aa[ni][nj] if pp[si][sj] == 0: print(1) exit() bb = np.zeros((h*w,h*w),dtype="f8") for i in range(h): for j in range(w): for di, dj in dij: ni, nj = di + i, dj + j if ni < 0 or nj < 0 or ni >= h or nj >= w: continue if pp[ni][nj]: bb[ni * w + nj][i * w + j] = 1 / pp[ni][nj] cc = np.eye(h*w,dtype="f8") while t: if t & 1: cc = np.dot(cc, bb) bb = np.dot(bb, bb) t >>= 1 ans = np.zeros((1,h*w),dtype="f8") ans[0][si * w + sj] = 1 ans = dot(ans, cc) print(ans[0][gi * w + gj]) h,w,t=MI() si,sj=MI() gi,gj=MI() aa=[[c=="#" for c in SI()] for _ in range(h)] solve(t)