#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int N = 1000 + 7, INF = 1e9 + 228;
char a[N][N];
int dist[N][N], l[N][N], r[N][N], u[N][N], d[N][N];
int n, m, k;
set<int> row[N], col[N];
inline void oh_kek() {
  for (int i = 1; i <= n; ++i) {
    int kek = 1;
    if (i == 1) {
      kek = 2;
    }
    for (int j = kek; j <= m; ++j) {
      if (a[i][j] != '#') {
        row[i].insert(j);
      }
    }
  }
  for (int j = 1; j <= m; ++j) {
    int kek = 1;
    if (j == 1) {
      kek = 2;
    }
    for (int i = kek; i <= n; ++i) {
      if (a[i][j] != '#') {
        col[j].insert(i);
      }
    }
  }
}
signed main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
      dist[i][j] = INF;
    }
  }
  for (int i = 1; i <= n; ++i) {
    l[i][0] = 1;
    for (int j = 1; j <= m; ++j) {
      if (a[i][j - 1] == '#') {
        l[i][j] = j;
      } else {
        l[i][j] = l[i][j - 1];
      }
    }
    r[i][m + 1] = m;
    for (int j = m; j >= 1; --j) {
      if (a[i][j + 1] == '#') {
        r[i][j] = j;
      } else {
        r[i][j] = r[i][j + 1];
      }
    }
  }
  for (int j = 1; j <= m; ++j) {
    u[0][j] = 1;
    for (int i = 1; i <= n; ++i) {
      if (a[i - 1][j] == '#') {
        u[i][j] = i;
      } else {
        u[i][j] = u[i - 1][j];
      }
    }
    d[n + 1][j] = n;
    for (int i = n; i >= 1; --i) {
      if (a[i + 1][j] == '#') {
        d[i][j] = i;
      } else {
        d[i][j] = d[i + 1][j];
      }
    }
  }
  int x1, y1, x2, y2;
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  queue<pair<int, int> > q;
  q.push({x1, y1});
  oh_kek();
  dist[x1][y1] = 0;
  while (!q.empty()) {
    pair<int, int> kek = q.front();
    q.pop();
    int x = kek.first, y = kek.second;
    int left228, right228;
    left228 = max(y - k, l[x][y]);
    right228 = min(y + k, r[x][y]);
    if (row[x].find(y) != row[x].end()) {
      row[x].erase(y);
    }
    if (col[y].find(x) != col[y].end()) {
      col[y].erase(x);
    }
    while (1) {
      set<int>::iterator it = row[x].lower_bound(left228);
      if (it == row[x].end()) break;
      int cur_y = (*it);
      if (left228 <= cur_y && cur_y <= right228) {
        dist[x][cur_y] = dist[x][y] + 1;
        q.push({x, cur_y});
        row[x].erase(cur_y);
        if (col[cur_y].find(x) != col[cur_y].end()) {
          col[cur_y].erase(x);
        }
      } else {
        break;
      }
    }
    left228 = max(x - k, u[x][y]);
    right228 = min(x + k, d[x][y]);
    while (1) {
      set<int>::iterator it = col[y].lower_bound(left228);
      if (it == col[y].end()) break;
      int cur_x = (*it);
      if (left228 <= cur_x && cur_x <= right228) {
        dist[cur_x][y] = dist[x][y] + 1;
        q.push({cur_x, y});
        col[y].erase(cur_x);
        if (row[cur_x].find(cur_x) != row[cur_x].end()) {
          row[cur_x].erase(y);
        }
      } else {
        break;
      }
    }
  }
  if (dist[x2][y2] == INF) {
    puts("-1");
  } else {
    printf("%d\n", dist[x2][y2]);
  }
  return 0;
}
