#include <bits/stdc++.h>
#pragma optimize("O2")
using namespace std;
const int inf = 1e7;
int n, m, k, xx1, xx2, yy1, yy2;
int a, b, c, d;
const int N = 1004;
int dp[N][N][4];
bool vis[N][N][4];
char s[N][N];
bool safe(int r, int c) {
  return (r >= 0 && c >= 0 && r < n && c < m && s[r][c] == '.');
}
struct Q {
  int r, c, dist, dir;
  Q() { r = c = dist = dir = 0; }
  Q(int a, int b, int z, int ch) { r = a, c = b, dir = z, dist = ch; }
};
void calc_min(int &x, int y) {
  if (x > y) x = y;
}
const int dx[] = {0, 0, -1, 1};
const int dy[] = {-1, 1, 0, 0};
void solve() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      for (int k = 0; k < 4; ++k) {
        dp[i][j][k] = inf;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  cin >> a >> b >> c >> d;
  if (a == c and b == d) {
    cout << 0 << '\n';
    return;
  }
  --a, --b, --c, --d;
  queue<Q> q;
  for (int i = 0; i < 4; ++i) {
    q.emplace(a, b, i, 0);
    dp[a][b][i] = 1;
  }
  while (!q.empty()) {
    auto it = q.front();
    int r, c, dir, rem_dist;
    q.pop();
    r = it.r, c = it.c, rem_dist = it.dist, dir = it.dir;
    ;
    if (vis[r][c][dir]) {
      continue;
    }
    vis[r][c][dir] = true;
    for (int i = 0; i < 4; ++i) {
      int new_r = r + dx[i];
      int new_c = c + dy[i];
      if (!safe(new_r, new_c)) {
        continue;
      };
      if (dir != i) {
        calc_min(dp[new_r][new_c][i], 1 + dp[r][c][dir]);
        q.emplace(new_r, new_c, i, 1);
      } else {
        if (rem_dist >= k) {
          calc_min(dp[new_r][new_c][i], 1 + dp[r][c][dir]);
          q.emplace(new_r, new_c, i, 1);
        } else {
          calc_min(dp[new_r][new_c][i], dp[r][c][dir]);
          q.emplace(new_r, new_c, i, rem_dist + 1);
        }
      }
    }
  };
  int ans = inf;
  for (int i = 0; i < 4; ++i) {
    ans = min(ans, dp[c][d][i]);
  }
  cout << (ans == inf ? -1 : ans) << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
