#include <bits/stdc++.h>
using namespace std;
using cd = complex<double>;
const int Inf = 1000000007;
const long long mod = 1000000007;
const double Pi = acos(-1);
void Fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int n, m, k;
int Dist[1005][1005];
char a[1005][1005];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  Fastio();
  cin >> 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;
    }
  }
  int x, y, z, t;
  cin >> x >> y >> z >> t;
  Dist[x][y] = 0;
  queue<pair<int, int> > BFS;
  BFS.push(make_pair(x, y));
  while (BFS.empty() == false) {
    int xx = BFS.front().first, yy = BFS.front().second;
    BFS.pop();
    for (int i = 0; i < 4; i++) {
      for (int j = 1; j <= k; j++) {
        int tempx = xx + dx[i] * j, tempy = yy + dy[i] * j;
        if (tempx == 0 or tempx == n + 1 or tempy == 0 or tempy == m + 1 or
            Dist[tempx][tempy] <= Dist[xx][yy] or a[tempx][tempy] == '#') {
          break;
        }
        if (Dist[tempx][tempy] > Dist[xx][yy] + 1) {
          Dist[tempx][tempy] = Dist[xx][yy] + 1;
          BFS.push(make_pair(tempx, tempy));
        }
      }
    }
  }
  if (Dist[z][t] == Inf) {
    cout << -1;
  } else {
    cout << Dist[z][t];
  }
  return 0;
}
