#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int n, m, k;
struct node {
  int x, y, step;
};
char s[maxn][maxn];
bool vis[maxn][maxn][4];
int go[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};
int bfs(int x, int y, int tx, int ty) {
  for (int i = 0; i < 4; ++i) vis[x][y][i] = 1;
  queue<node> q;
  node tmp, tem;
  tem.x = x, tem.y = y, tem.step = 0;
  q.push(tem);
  int xx, yy;
  while (!q.empty()) {
    tmp = q.front();
    q.pop();
    if (tmp.x == tx && tmp.y == ty) return tmp.step;
    for (int i = 0; i < 4; i++) {
      tem = tmp;
      tem.step++;
      for (int j = 1; j <= k; j++) {
        xx = tem.x + go[i][0];
        yy = tem.y + go[i][1];
        if (xx < 0 || xx > n) break;
        if (yy < 0 || yy > m) break;
        if (s[xx][yy] != '.') break;
        if (vis[xx][yy][i]) break;
        tem.x = xx;
        tem.y = yy;
        vis[xx][yy][i] = 1;
        q.push(tem);
      }
    }
  }
  return -1;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  int x, xx, y, yy;
  scanf("%d%d%d%d", &x, &y, &xx, &yy);
  printf("%d\n", bfs(x, y, xx, yy));
  return 0;
}
