#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
const int INF = 1e9 + 7;
int n, m, k;
char g[N][N];
int d[N][N];
bool used[N][N];
void _init_d() {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) d[i][j] = INF;
}
int bfs(int x1, int y1, int x2, int y2) {
  queue<pair<int, int> > q;
  q.push({x1, y1});
  d[x1][y1] = 0;
  used[x1][y1] = true;
  while (q.size()) {
    pair<int, int> v = q.front();
    q.pop();
    int x = v.first, y = v.second;
    for (int i = x - 1, r = 1;
         i >= 0 && g[i][y] == '.' && d[i][y] >= d[x][y] + 1 && r <= k;
         i--, r++) {
      if (used[i][y]) continue;
      used[i][y] = true;
      d[i][y] = d[x][y] + 1;
      q.push({i, y});
    }
    for (int i = x + 1, r = 1;
         i < n && g[i][y] == '.' && d[i][y] >= d[x][y] + 1 && r <= k;
         i++, r++) {
      if (used[i][y]) continue;
      used[i][y] = true;
      d[i][y] = d[x][y] + 1;
      q.push({i, y});
    }
    for (int i = y - 1, r = 1;
         i >= 0 && g[x][i] == '.' && d[x][i] >= d[x][y] + 1 && r <= k;
         i--, r++) {
      if (used[x][i]) continue;
      used[x][i] = true;
      d[x][i] = d[x][y] + 1;
      q.push({x, i});
    }
    for (int i = y + 1, r = 1;
         i < m && g[x][i] == '.' && d[x][i] >= d[x][y] + 1 && r <= k;
         i++, r++) {
      if (used[x][i]) continue;
      used[x][i] = true;
      d[x][i] = d[x][y] + 1;
      q.push({x, i});
    }
  }
  return (d[x2][y2] >= INF ? -1 : d[x2][y2]);
}
int main() {
  _init_d();
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> g[i];
  int sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  cout << bfs(sx - 1, sy - 1, fx - 1, fy - 1) << endl;
}
