#include <bits/stdc++.h>
using namespace std;
int N, M, K, R1, R2, C1, C2;
string grid[1100];
bool seen[1100][1100];
void input() {
  cin >> N >> M >> K;
  for (int i = 1; i <= N; i++) {
    cin >> grid[i];
    grid[i] = "#" + grid[i];
  }
  cin >> R1 >> C1 >> R2 >> C2;
}
int solve() {
  deque<pair<pair<int, int>, int> > Q;
  Q.push_back({{R1, C1}, 0});
  seen[R1][C1] = true;
  while (!Q.empty()) {
    pair<pair<int, int>, int> cur = Q.front();
    Q.pop_front();
    int at_r = cur.first.first;
    int at_c = cur.first.second;
    int dist = cur.second;
    if (at_r == R2 && at_c == C2) return dist;
    int r, c;
    for (r = at_r - 1, c = at_c; r >= 1 && r >= at_r - K; r--) {
      if (r == R2 && c == C2) return dist + 1;
      if (grid[r][c] == '#') break;
      if (!seen[r][c]) {
        seen[r][c] = true;
        Q.push_back({{r, c}, dist + 1});
      }
    }
    for (c = at_c + 1, r = at_r; c <= M && c <= at_c + K; c++) {
      if (r == R2 && c == C2) return dist + 1;
      if (grid[r][c] == '#') break;
      if (!seen[r][c]) {
        seen[r][c] = true;
        Q.push_back({{r, c}, dist + 1});
      }
    }
    for (r = at_r + 1, c = at_c; r <= N && r <= at_r + K; r++) {
      if (r == R2 && c == C2) return dist + 1;
      if (grid[r][c] == '#') break;
      if (!seen[r][c]) {
        seen[r][c] = true;
        Q.push_back({{r, c}, dist + 1});
      }
    }
    for (c = at_c - 1, r = at_r; c >= 1 && c >= at_c - K; c--) {
      if (r == R2 && c == C2) return dist + 1;
      if (grid[r][c] == '#') break;
      if (!seen[r][c]) {
        seen[r][c] = true;
        Q.push_back({{r, c}, dist + 1});
      }
    }
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  cout << solve();
  return 0;
}
