#include <bits/stdc++.h>
using namespace std;
const int lim = (int)(1e3 + 5);
int fl = 1, ans = INT_MAX, n, m, k, mark[lim][lim], stx, sty, fx, fy,
    dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}},
    yol[24][4] = {{1, 2, 3, 4}, {1, 2, 4, 3}, {1, 3, 2, 4}, {1, 3, 4, 2},
                  {1, 4, 2, 3}, {1, 4, 3, 2}, {2, 1, 3, 4}, {2, 1, 4, 3},
                  {2, 3, 1, 4}, {2, 3, 4, 1}, {2, 4, 1, 3}, {2, 4, 3, 1},
                  {3, 1, 2, 4}, {3, 1, 4, 2}, {3, 2, 1, 4}, {3, 2, 4, 1},
                  {3, 4, 1, 2}, {3, 4, 2, 1}, {4, 1, 2, 3}, {4, 1, 3, 2},
                  {4, 2, 1, 3}, {4, 2, 3, 1}, {4, 3, 1, 2}, {4, 3, 2, 1}};
char a[lim][lim];
struct info {
  int x, y, st, dr, hw;
};
info mi(int _x, int _y, int _st, int _dr, int _hw) {
  return (info){_x, _y, _st, _dr, _hw};
}
void bfs(int x, int y, int go) {
  queue<info> q;
  q.push(mi(x, y, 0, -1, 0));
  while (!q.empty()) {
    info t = q.front();
    q.pop();
    for (int i = 0; i <= 3; i++) {
      int nx = t.x + dir[yol[go][i] - 1][0], ny = t.y + dir[yol[go][i] - 1][1];
      if (nx <= n && ny <= m && nx >= 1 && ny >= 1 && a[nx][ny] != '#' &&
          mark[nx][ny] == 0) {
        if (t.hw + 1 <= k) {
          if (t.dr == i) {
            mark[nx][ny] = mark[t.x][t.y];
            q.push(mi(nx, ny, t.st, t.dr, t.hw + 1));
          } else {
            mark[nx][ny] = mark[t.x][t.y] + 1;
            q.push(mi(nx, ny, t.st + 1, i, 1));
          }
        } else {
          mark[nx][ny] = mark[t.x][t.y] + 1;
          q.push(mi(nx, ny, t.st + 1, i, 1));
        }
      }
    }
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf(" %c", &a[i][j]);
  scanf("%d %d %d %d", &stx, &sty, &fx, &fy);
  if (stx == fx && sty == fy) return printf("0"), 0;
  for (int i = 0; i < 24; i++) {
    memset(mark, 0, sizeof(mark));
    mark[stx][sty] = 1;
    bfs(stx, sty, i);
    if (mark[fx][fy] != -1) {
      fl = 1;
      ans = min(ans, mark[fx][fy]);
    }
  }
  if (fl)
    printf("%d", ans - 1);
  else
    printf("-1");
}
