#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int R, C, k;
set<int> row[N], col[N];
char g[N][N + 1];
int cost[N][N];
int cs[N][N];
bool bad(int r1, int c1, int r2, int c2) {
  if (r1 > r2) swap(r1, r2);
  if (c1 > c2) swap(c1, c2);
  int sum = cs[r2][c2];
  if (r1) sum -= cs[r1 - 1][c2];
  if (c1) sum -= cs[r2][c1 - 1];
  if (r1 && c1) sum += cs[r1 - 1][c1 - 1];
  return sum > 0;
}
int main() {
  scanf("%d%d%d", &R, &C, &k);
  for (int i = 0; i < R; ++i) {
    scanf("%s", g[i]);
    for (int j = 0; j < C; ++j)
      if (g[i][j] == '.') {
        row[i].insert(j);
        col[j].insert(i);
      } else
        cs[i][j] = 1;
  }
  for (int i = 0; i < R; ++i)
    for (int j = 0; j < C; ++j) {
      if (i) cs[i][j] += cs[i - 1][j];
      if (j) cs[i][j] += cs[i][j - 1];
      if (i && j) cs[i][j] -= cs[i - 1][j - 1];
    }
  for (int i = 0; i < R; ++i) {
    row[i].insert(-1e9);
    row[i].insert(1e9);
  }
  for (int i = 0; i < C; ++i) {
    col[i].insert(-1e9);
    col[i].insert(1e9);
  }
  int r1, c1, r2, c2;
  scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
  --r1;
  --r2;
  --c1;
  --c2;
  queue<pair<int, int> > q;
  q.push(make_pair(r1, c1));
  row[r1].erase(c1);
  col[c1].erase(r1);
  pair<int, int> u;
  int r, c;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    r = u.first;
    c = u.second;
    if (r == r2 && c == c2) {
      printf("%d\n", cost[r][c]);
      return 0;
    }
    auto it = row[r].lower_bound(c);
    while (*it - c <= k) {
      if (bad(r, c, r, *it)) break;
      cost[r][*it] = cost[r][c] + 1;
      q.push(make_pair(r, *it));
      col[*it].erase(r);
      row[r].erase(it++);
    }
    it = row[r].lower_bound(c);
    --it;
    while (c - *it <= k) {
      if (bad(r, c, r, *it)) break;
      cost[r][*it] = cost[r][c] + 1;
      q.push(make_pair(r, *it));
      col[*it].erase(r);
      row[r].erase(it--);
    }
    it = col[c].lower_bound(r);
    while (*it - r <= k) {
      if (bad(r, c, *it, c)) break;
      cost[*it][c] = cost[r][c] + 1;
      q.push(make_pair(*it, c));
      row[*it].erase(c);
      col[c].erase(it++);
    }
    it = col[c].lower_bound(r);
    --it;
    while (r - *it <= k) {
      if (bad(r, c, *it, c)) break;
      cost[*it][c] = cost[r][c] + 1;
      q.push(make_pair(*it, c));
      row[*it].erase(c);
      col[c].erase(it--);
    }
  }
  puts("-1");
  return 0;
}
