import java.io.*; import java.util.*; public class _p1570_Validate { public static void main(String[] args) throws IOException { new _p1570_Validate().solve(); } static int mod = (int)1e9+7; void solve() throws IOException { try (final InputValidator in = new InputValidator(System.in)) { int h = in.nextInt(3, 10); in.space(); int w = in.nextInt(3, 10); in.space(); int t = in.nextInt(1, 1_000_000_00); in.newLine(); int sy = in.nextInt(1, 8); in.space(); int sx = in.nextInt(1, 8); in.newLine(); int gy = in.nextInt(1, 8); in.space(); int gx = in.nextInt(1, 8); in.newLine(); char[][] map = new char[h][w]; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { map[y][x] = in.nextChar(); if (x == w - 1) in.newLine(); if (map[y][x] != '.' && map[y][x] != '#') throw new RuntimeException(); if (x % (w-1) == 0 && map[y][x] == '.') throw new RuntimeException(); if (y % (h-1) == 0 && map[y][x] == '.') throw new RuntimeException(); } } in.eof(); double[][] prob = new double[w*h][w*h]; int[] d = new int[]{1, 0, -1, 0, 1}; for (int y = 1; y < h - 1; y++) { for (int x = 1; x < w - 1; x++) if (map[y][x] == '.') { int cnt = 0; for (int i = 0; i < 4; i++) { int x2 = x + d[i]; int y2 = y + d[i+1]; if (map[y2][x2] == '.') { cnt++; prob[y*w+x][y2*w+x2] = 1; } } if (cnt == 0) { prob[y*w+x][y*w+x] = 1; } else { for (int i = 0; i < prob[y*w+x].length; i++) { prob[y*w+x][i] /= cnt; } } } } double[][] ans = new double[w*h][w*h]; for (int i = 0; i < ans.length; i++) ans[i][i] = 1; for (int i = 1; i <= t; i <<= 1) { if ((t&i) != 0) { ans = mulmat(ans, prob); } prob = mulmat(prob, prob); } System.out.printf("%.10f\n", ans[sy*w+sx][gy*w+gx]); } } // a [n,v] * b [v,m] => c[n,m] static double[][] mulmat(double[][] a, double[][] b) { final long BIG = (2L * mod) * (2L * mod); assert(a[0].length == b.length); final int n = a.length; final int v = b.length; final int m = b[0].length; double[][] res = new double[n][m]; for(int i = 0; i < n; i++) for(int k = 0; k < v; k++) { final double aa = a[i][k]; for(int j = 0; j < m; j++) { res[i][j] += aa * b[k][j]; if(res[i][j] >= BIG) res[i][j] -= BIG; } } for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) res[i][j] %= mod; return res; } static double[][] powmat(long r, double[][] mat) { final int n = mat.length; double[][] x = new double[n][n]; for(int i = 0; i < n; i++) { x[i][i] = 1; } for(;r > 0; r >>>= 1) { if((r&1) == 1) { x = mulmat(x, mat); } mat = mulmat(mat, mat); } return x; } // for debug static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); } static class InputValidator implements Closeable { final InputStream in; final int NO_BUFFER = -2; int buffer; public InputValidator(final InputStream in) { this.in = in; buffer = NO_BUFFER; } public char nextChar() throws IOException { int res = read(); check("#.".indexOf((char)res) >= 0 || Character.isLetterOrDigit(res)); return (char)res; } int read() throws IOException { final int res = buffer == NO_BUFFER ? in.read() : buffer; buffer = NO_BUFFER; return res; } void unread(int ch) throws IOException { buffer = ch; } // [low, high] long nextLong(long low, long high) throws IOException { long val = 0; int ch = -1; boolean read = false; while (true) { ch = read(); if (!Character.isDigit(ch)) break; read = true; val = val * 10 + ch - '0'; check(val <= high); } check(read); check(ch >= 0); check(val >= low); unread(ch); return val; } int nextInt(int low, int high) throws IOException { return (int)nextLong(low, high); } int[] nextInts(int n, int low, int high) throws IOException { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = nextInt(low, high); if (i + 1 != n) space(); } newLineOrEOF(); return res; } void space() throws IOException { int ch = read(); check(ch == ' '); } void newLine() throws IOException { int ch = read(); if (ch == '\r') ch = read(); check(ch == '\n'); } void newLineOrEOF() throws IOException { int ch = read(); check(ch == '\r' || ch == '\n' || ch < 0); } void eof() throws IOException { int ch = read(); check(ch < 0); } void check(boolean b) { if (!b) throw new RuntimeException(); } @Override public void close() throws IOException { } } }