import numpy as np import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) def main(): dydx4 = ((0, 1), (1, 0), (-1, 0), (0, -1)) h, w, t = map(int, input().split()) sx, sy = map(int, input().split()) gx, gy = map(int, input().split()) S = [input() for _ in range(h)] d = abs(sx-gx)+abs(sy-gy) if (t-d) % 2 == 1 or d > t: return 0.0 blank = [] for x in range(h): for y in range(w): if S[x][y] == ".": blank.append(x*w+y) n = len(blank) btoi = {b: i for i, b in enumerate(blank)} A = [0] * (n+1) G = [[0]*(n+1) for _ in range(n+1)] A[btoi[sx*w+sy]] = 1.0 A[n] = 1.0 for i in range(n+1): G[i][n] = 1. for x in range(h): for y in range(w): if S[x][y] == ".": i = btoi[x*w+y] p = 0 for dx, dy in dydx4: nx = x+dx ny = y+dy p += int(S[nx][ny] == ".") if p == 0: G[i][n] = 0 G[i][i] = 1.0 continue for dx, dy in dydx4: nx = x+dx ny = y+dy if 0 <= nx < h and 0 <= ny < w and S[nx][ny] == ".": j = btoi[nx*w+ny] G[j][i] = 1./p GG = np.linalg.matrix_power(G, t).tolist() res = 0. goal = btoi[gx*w+gy] for i in range(n): res += GG[goal][i] * A[i] return res print("{:.18f}".format(main()))