#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, INF = 1e9 + 7;
int i, j, n, m, k, ans, res, x, y;
int a[N], d[N], b[1005][1005], f[1005][1005];
bool u[N];
vector<long long> v;
string st;
char s[1005][1005];
queue<pair<int, int> > q;
int main() {
  ios_base::sync_with_stdio(0);
  int xx, yy;
  cin >> n >> m >> k;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> s[i][j];
  cin >> x >> y >> xx >> yy;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      b[i][j] = 1e9;
    }
  b[x][y] = 0;
  q.push(make_pair(x, y));
  while (!q.empty()) {
    pair<int, int> z = q.front();
    q.pop();
    x = z.first, y = z.second;
    for (i = x - 1;
         i >= max(1, x - k) && s[i][y] == '.' && b[i][y] >= b[x][y] + 1; i--) {
      if (!f[i][y]) {
        b[i][y] = b[x][y] + 1;
        q.push(make_pair(i, y));
        f[i][y] = 1;
      }
    }
    for (i = x + 1;
         i <= min(n, x + k) && s[i][y] == '.' && b[i][y] >= b[x][y] + 1; i++) {
      if (!f[i][y]) {
        b[i][y] = b[x][y] + 1;
        q.push(make_pair(i, y));
        f[i][y] = 1;
      }
    }
    for (j = y + 1;
         j <= min(m, y + k) && s[x][j] == '.' && b[x][j] >= b[x][y] + 1; j++) {
      if (!f[x][j]) {
        b[x][j] = b[x][y] + 1;
        q.push(make_pair(x, j));
        f[x][j] = 1;
      }
    }
    for (j = y - 1;
         j >= max(1, y - k) && s[x][j] == '.' && b[x][j] >= b[x][y] + 1; j--) {
      if (!f[x][j]) {
        b[x][j] = b[x][y] + 1;
        q.push(make_pair(x, j));
        f[x][j] = 1;
      }
    }
  }
  if (b[xx][yy] == 1e9)
    cout << -1;
  else
    cout << b[xx][yy];
}
