#include <bits/stdc++.h>
using namespace std;
bool table[1005][1005];
bool was[1005][1005];
int level[1005][1005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char ch;
      cin >> ch;
      table[i][j] = (ch == '#');
    }
  }
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  if (table[x1][y1] || table[x2][y2]) {
    cout << -1;
    return 0;
  }
  was[x1][y1] = true;
  queue<pair<int, int> > qu;
  qu.push(make_pair(x1, y1));
  level[x1][y1] = 0;
  while (!was[x2][y2] && !qu.empty()) {
    auto pr = qu.front();
    int x = pr.first;
    int y = pr.second;
    qu.pop();
    vector<pair<int, int> > topush;
    vector<bool> gothisway(4, true);
    for (int i = 1; i <= k; i++) {
      if (!gothisway[0] && !gothisway[1] && !gothisway[2] && !gothisway[3]) {
        break;
      }
      if (gothisway[0] && x - i > 0 && !table[x - i][y]) {
        if (!was[x - i][y]) {
          topush.push_back(make_pair(x - i, y));
          was[x - i][y] = true;
        }
      } else {
        gothisway[0] = false;
      }
      if (gothisway[1] && x + i <= n && !table[x + i][y]) {
        if (!was[x + i][y]) {
          topush.push_back(make_pair(x + i, y));
          was[x + i][y] = true;
        }
      } else {
        gothisway[1] = false;
      }
      if (gothisway[2] && y - i > 0 && !table[x][y - i]) {
        if (!was[x][y - i]) {
          topush.push_back(make_pair(x, y - i));
          was[x][y - i] = true;
        }
      } else {
        gothisway[2] = false;
      }
      if (gothisway[3] && y + i <= m && !table[x][y + i]) {
        if (!was[x][y + i]) {
          topush.push_back(make_pair(x, y + i));
          was[x][y + i] = true;
        }
      } else {
        gothisway[3] = false;
      }
    }
    for (int i = topush.size() - 1; i >= 0; i--) {
      qu.push(topush[i]);
      level[topush[i].first][topush[i].second] = level[x][y] + 1;
    }
  }
  if (!was[x2][y2]) {
    cout << -1;
  } else {
    cout << level[x2][y2];
  }
  return 0;
}
