#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int n, m, mat[maxn][maxn], k, h[maxn][maxn], x, y;
set<int> col[maxn], row[maxn];
void bfs() {
  h[x][y] = 0;
  row[x].erase(y);
  col[y].erase(x);
  queue<pair<int, int>> q;
  q.push({x, y});
  while (q.size()) {
    int a = q.front().first, b = q.front().second;
    vector<pair<int, int>> v;
    auto it = row[a].lower_bound(b);
    auto i = it;
    while (i != row[a].end()) {
      int c = a, d = (*i);
      if (d > b + k || mat[c][d]) break;
      v.push_back({c, d});
      i++;
    }
    i = it;
    if (i != row[a].begin()) {
      i--;
      while (i != row[a].end()) {
        int c = a, d = (*i);
        if (d < b - k || mat[c][d]) break;
        v.push_back({c, d});
        if (i == row[a].begin()) break;
        i--;
      }
    }
    it = col[b].lower_bound(a);
    i = it;
    while (i != col[b].end()) {
      int c = (*i), d = b;
      if (c > a + k || mat[c][d]) break;
      v.push_back({c, d});
      i++;
    }
    i = it;
    if (i != col[b].begin()) {
      i--;
      while (i != col[b].end()) {
        int c = (*i), d = b;
        if (c < a - k || mat[c][d]) break;
        v.push_back({c, d});
        if (i == col[b].begin()) break;
        i--;
      }
    }
    for (pair<int, int> x : v) {
      int c = x.first, d = x.second;
      row[c].erase(d);
      col[d].erase(c);
      h[c][d] = h[a][b] + 1;
      q.push({c, d});
    }
    q.pop();
  }
}
int main() {
  memset(h, -1, sizeof(h));
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      if (c == '#') {
        mat[i][j] = 1;
      }
      row[i].insert(j);
      col[j].insert(i);
    }
  }
  cin >> x >> y;
  x--;
  y--;
  bfs();
  int a, b;
  cin >> a >> b;
  a--;
  b--;
  cout << h[a][b];
  cout << endl;
  return 0;
}
