#include <bits/stdc++.h>
using namespace std;
void doRoutine() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
const int N = 1005, M = 1005;
bool arr[N][M];
map<pair<int, int>, int> dist;
set<int> hors[N];
set<int> verts[M];
int lb[N][M];
int rb[N][M];
int tb[N][M];
int bb[N][M];
void del(pair<int, int> x) {
  hors[x.first].erase(x.second);
  verts[x.second].erase(x.first);
}
int main() {
  doRoutine();
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      char c;
      cin >> c;
      arr[i][j] = (c == '.');
      hors[i].insert(j);
      verts[j].insert(i);
    }
  }
  for (int i = 0; i < n; ++i) {
    int cur_left = 0;
    for (int j = 0; j < m; ++j) {
      if (!arr[i][j]) {
        cur_left = j + 1;
      }
      lb[i][j] = cur_left;
    }
    int cur_right = m - 1;
    for (int j = m - 1; j > -1; --j) {
      if (!arr[i][j]) {
        cur_right = j - 1;
      }
      rb[i][j] = cur_right;
    }
  }
  for (int j = 0; j < m; ++j) {
    int cur_top = 0;
    for (int i = 0; i < n; ++i) {
      if (!arr[i][j]) {
        cur_top = i + 1;
      }
      tb[i][j] = cur_top;
    }
    int cur_bot = n - 1;
    for (int i = n - 1; i > -1; --i) {
      if (!arr[i][j]) {
        cur_bot = i - 1;
      }
      bb[i][j] = cur_bot;
    }
  }
  pair<int, int> s, t;
  cin >> s.first >> s.second >> t.first >> t.second;
  --s.first;
  --s.second;
  --t.first;
  --t.second;
  queue<pair<int, int> > q;
  q.push(s);
  dist[s] = 0;
  del(s);
  while (!q.empty()) {
    auto cur = q.front();
    q.pop();
    int dst = dist[cur];
    int i = cur.first, j = cur.second;
    int l = max(lb[i][j], j - k);
    int r = min(rb[i][j], j + k);
    int t = max(tb[i][j], i - k);
    int b = min(bb[i][j], i + k);
    auto v1 = verts[j].lower_bound(t), v2 = verts[j].upper_bound(b);
    auto h1 = hors[i].lower_bound(l), h2 = hors[i].upper_bound(r);
    vector<pair<int, int> > todel;
    for (auto it = h1; it != h2; ++it) {
      dist[{i, *it}] = dst + 1;
      todel.push_back({i, *it});
      q.push({i, *it});
    }
    for (auto x : todel) {
      del(x);
    }
    todel.clear();
    for (auto it = v1; it != v2; ++it) {
      dist[{*it, j}] = dst + 1;
      todel.push_back({*it, j});
      q.push({*it, j});
    }
    for (auto x : todel) {
      del(x);
    }
  }
  if (dist.find(t) == dist.end()) {
    cout << -1 << endl;
  } else {
    cout << dist[t] << endl;
  }
  return 0;
}
