import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.HashSet; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int R = sc.nextInt(); int C = sc.nextInt(); int T = sc.nextInt(); int Sy = sc.nextInt(); int Sx = sc.nextInt(); int Gy = sc.nextInt(); int Gx = sc.nextInt(); char[][] map = new char[R][C]; for (int i = 0; i < R; ++i) { map[i] = sc.next().toCharArray(); } double[][] to = new double[R * C][R * C]; for (int i = 0; i < R; ++i) { for (int j = 0; j < C; ++j) { if (map[i][j] == '#') continue; double cnt = 0; for (int di = -1; di <= 1; ++di) { for (int dj = -1; dj <= 1; ++dj) { if (Math.abs(di) + Math.abs(dj) != 1) continue; if (i + di < 0 || i + di >= R || j + dj < 0 || j + dj >= C || map[i + di][j + dj] == '#') continue; ++cnt; } } if (cnt == 0) { to[i * C + j][i * C + j] = 1; } else { for (int di = -1; di <= 1; ++di) { for (int dj = -1; dj <= 1; ++dj) { if (Math.abs(di) + Math.abs(dj) != 1) continue; if (i + di < 0 || i + di >= R || j + dj < 0 || j + dj >= C || map[i + di][j + dj] == '#') continue; to[(i + di) * C + (j + dj)][i * C + j] += 1 / cnt; } } } } } double[][] vec = new double[R * C][1]; vec[Sy * C + Sx][0] = 1; vec = mul(pow(to, T), vec); System.out.println(vec[Gy * C + Gx][0]); } double[][] pow(double[][] A, long n) { double[][] ret = new double[A.length][A.length]; for (int i = 0; i < A.length; ++i) ret[i][i] = 1; for (; n > 0; n >>= 1, A = mul(A, A)) { if (n % 2 == 1) { ret = mul(A, ret); } } return ret; } double[][] mul(double[][] a, double[][] b) { double[][] ret = new double[a.length][b[0].length]; for (int i = 0; i < a.length; ++i) { for (int j = 0; j < b[i].length; ++j) { for (int k = 0; k < a[0].length; ++k) { ret[i][j] += a[i][k] * b[k][j]; } } } return ret; } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }