#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, k;
struct node {
  int x, y, t;
} point, now;
int maps[1001][1001];
int vis[1001][1001];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int sx, sy;
int ans;
int check(int x, int y) { return x >= 1 && x <= n && y >= 1 && y <= m; }
int ex, ey;
void bfs(int a, int b) {
  queue<node> q;
  point.x = a;
  point.y = b;
  q.push(point);
  vis[a][b] = (1 << 4) - 1;
  while (!q.empty()) {
    now = q.front();
    q.pop();
    if (now.x == ex && now.y == ey) {
      ans = now.t;
      return;
    }
    for (int i = 0; i <= 3; i++) {
      for (int j = 1; j <= k; j++) {
        point.x = now.x + dx[i] * j;
        point.y = now.y + dy[i] * j;
        if (maps[point.x][point.y]) break;
        if (!check(point.x, point.y)) break;
        if (vis[point.x][point.y] & (1 << i)) break;
        int f = 0;
        if (!vis[point.x][point.y]) f = 1;
        vis[point.x][point.y] |= (1 << i);
        if (f) {
          point.t = now.t + 1;
          q.push(point);
        }
      }
    }
  }
}
int main() {
  n = read();
  m = read();
  k = read();
  char c;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c;
      if (c == '#') maps[i][j] = 1;
    }
  sx = read();
  sy = read();
  ex = read();
  ey = read();
  bfs(sx, sy);
  if (vis[ex][ey])
    printf("%d", ans);
  else
    printf("-1");
  return 0;
}
