#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T bigmod(T p, T e, T M) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long int t = bigmod(p, e / 2, M);
    return (T)((t * t) % M);
  }
  return (T)((long long int)bigmod(p, e - 1, M) * (long long int)p) % M;
}
template <class T>
inline T bigexp(T p, T e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long int t = bigexp(p, e / 2);
    return (T)((t * t));
  }
  return (T)((long long int)bigexp(p, e - 1) * (long long int)p);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
int dx4[] = {1, 0, -1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
int nx8[] = {1, 1, -1, -1, 2, 2, -2, -2};
int ny8[] = {2, -2, 2, -2, 1, -1, 1, -1};
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, m, k, dp[1005][1005][4][2], a1, b1, a2, b2;
char s[1005][1005];
struct data {
  int x, y, remk, sec, dir;
};
bool isvalid(int a, int b) {
  return a >= 0 && a < n && b >= 0 && b < m && s[a][b] == '.';
}
int bfs() {
  queue<data> q;
  data u, v;
  u.x = a1;
  u.y = b1;
  u.remk = 0;
  u.sec = 0;
  u.dir = 0;
  q.push(u);
  for (__typeof(n - 1) i = (0); i <= (n - 1); i++)
    for (__typeof(m - 1) j = (0); j <= (m - 1); j++)
      for (__typeof(3) k = (0); k <= (3); k++) {
        dp[i][j][k][0] = 0;
        dp[i][j][k][1] = 1000000000;
      }
  int res = 1000000000, x, y, d;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    x = u.x;
    y = u.y;
    for (int i = 0; i < 4; i++) {
      if ((bool)isvalid(x + dx4[i], y + dy4[i]) == true) {
        v.x = x + dx4[i];
        v.y = y + dy4[i];
        d = u.dir;
        if (d == 0)
          d = 2;
        else if (d == 2)
          d = 0;
        else if (d == 1)
          d = 3;
        else
          d = 1;
        if (i == u.dir) {
          v.dir = i;
          if (u.remk == 0) {
            v.remk = k - 1;
            v.sec = u.sec + 1;
          } else {
            v.remk = u.remk - 1;
            v.sec = u.sec;
          }
          if (dp[v.x][v.y][v.dir][1] > v.sec) {
            dp[v.x][v.y][v.dir][1] = v.sec;
            dp[v.x][v.y][v.dir][0] = v.remk;
            q.push(v);
          } else if (dp[v.x][v.y][v.dir][1] == v.sec) {
            if (dp[v.x][v.y][v.dir][0] < v.remk) {
              dp[v.x][v.y][v.dir][1] = v.sec;
              dp[v.x][v.y][v.dir][0] = v.remk;
              q.push(v);
            }
          }
        } else {
          v.dir = i;
          v.remk = k - 1;
          v.sec = u.sec + 1;
          if (dp[v.x][v.y][v.dir][1] > v.sec) {
            dp[v.x][v.y][v.dir][1] = v.sec;
            dp[v.x][v.y][v.dir][0] = v.remk;
            q.push(v);
          } else if (dp[v.x][v.y][v.dir][1] == v.sec) {
            if (dp[v.x][v.y][v.dir][0] < v.remk) {
              dp[v.x][v.y][v.dir][1] = v.sec;
              dp[v.x][v.y][v.dir][0] = v.remk;
              q.push(v);
            }
          }
        }
      }
    }
  }
  for (int k = 0; k <= 3; k++) {
    res = min(res, dp[a2][b2][k][1]);
  }
  return res;
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%d", &k);
  for (__typeof(n - 1) i = (0); i <= (n - 1); i++) scanf("%s", &s[i]);
  scanf("%d %d", &a1, &b1);
  scanf("%d %d", &a2, &b2);
  a1--;
  b1--;
  a2--;
  b2--;
  int res = bfs();
  if (res == 1000000000) res = -1;
  if (a1 == a2 && b1 == b2) res = 0;
  cout << res;
  return 0;
}
