#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int mp[1010][1010];
int flag[1010][1010];
int stx, sty, edx, edy;
queue<pair<int, int> > q;
int l[1010][1010], r[1010][1010], u[1010][1010], d[1010][1010];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  char ins;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> ins;
      if (ins == '.')
        mp[i][j] = 0;
      else
        mp[i][j] = 1;
      l[i][j] = i - 1;
      r[i][j] = i + 1;
      d[i][j] = j - 1;
      u[i][j] = j + 1;
    }
  cin >> stx >> sty >> edx >> edy;
  stx--, sty--, edx--, edy--;
  memset(flag, -1, sizeof flag);
  flag[stx][sty] = 0;
  q.push(make_pair(stx, sty));
  int x, y, tox, toy, tlx, tly, tl;
  while (!q.empty()) {
    x = q.front().first;
    y = q.front().second;
    q.pop();
    for (tox = x - 1; tox >= 0 && mp[tox][y] != 1 && x - tox <= k;
         tox = l[tox][y])
      if (flag[tox][y] == -1)
        flag[tox][y] = flag[x][y] + 1, q.push(make_pair(tox, y));
    for (tlx = x - 1; tlx >= 0 && mp[tlx][y] != 1 && x - tlx <= k;)
      tl = tlx, tlx = l[tlx][y], l[tl][y] = tox;
    for (tox = x + 1; tox < n && mp[tox][y] != 1 && tox - x <= k;
         tox = r[tox][y])
      if (flag[tox][y] == -1)
        flag[tox][y] = flag[x][y] + 1, q.push(make_pair(tox, y));
    for (tlx = x + 1; tlx < n && mp[tlx][y] != 1 && tlx - x <= k;)
      tl = tlx, tlx = r[tlx][y], r[tl][y] = tox;
    for (toy = y - 1; toy >= 0 && mp[x][toy] != 1 && y - toy <= k;
         toy = d[x][toy])
      if (flag[x][toy] == -1)
        flag[x][toy] = flag[x][y] + 1, q.push(make_pair(x, toy));
    for (tly = y - 1; tly >= 0 && mp[x][tly] != 1 && y - tly <= k;)
      tl = tly, tly = d[x][tly], d[x][tl] = toy;
    for (toy = y + 1; toy < m && mp[x][toy] != 1 && toy - y <= k;
         toy = u[x][toy])
      if (flag[x][toy] == -1)
        flag[x][toy] = flag[x][y] + 1, q.push(make_pair(x, toy));
    for (tly = y + 1; tly < m && mp[x][tly] != 1 && tly - y <= k;)
      tl = tly, tly = u[x][tly], u[x][tl] = toy;
    if (flag[edx][edy] != -1) {
      cout << flag[edx][edy] << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
