#include <bits/stdc++.h>
using namespace std;
vector<vector<char>> v;
vector<vector<long long>> d;
vector<set<long long>> row, col;
long long h, w, k, xs, xe, ye, ys;
queue<pair<long long, long long>> q;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> h >> w >> k;
  vector<char> tmp;
  vector<long long> tmp2;
  set<long long> tmp3;
  for (long long i = 1; i <= h + 1; i++) {
    v.push_back(tmp);
    d.push_back(tmp2);
    row.push_back(tmp3);
  }
  for (long long i = 1; i <= w + 1; i++) col.push_back(tmp3);
  for (long long i = 1; i <= h; i++) {
    v[i].push_back('#');
    d[i].push_back(1000000000000000000);
    for (long long j = 1; j <= w; j++) {
      char f;
      cin >> f;
      v[i].push_back(f);
      row[i].insert(j);
      col[j].insert(i);
      d[i].push_back(1000000000000000000);
    }
  }
  cin >> xs >> ys >> xe >> ye;
  d[xs][ys] = 0;
  q.push({xs, ys});
  row[xs].erase(ys);
  col[ys].erase(xs);
  while (!q.empty()) {
    long long x = q.front().first, y = q.front().second;
    q.pop();
    auto it1 = row[x].lower_bound(y);
    while (it1 != row[x].end() && v[x][*it1] != '#' && *it1 - y <= k) {
      d[x][*it1] = d[x][y] + 1;
      q.push({x, *it1});
      col[*it1].erase(x);
      row[x].erase(it1++);
    }
    auto it2 = row[x].lower_bound(y);
    if (it2 != row[x].begin()) {
      it2 = prev(it2);
      while (v[x][*it2] != '#' && y - *it2 <= k) {
        d[x][*it2] = d[x][y] + 1;
        q.push({x, *it2});
        col[*it2].erase(x);
        if (it2 == row[x].begin()) {
          row[x].erase(it2);
          break;
        } else
          row[x].erase(it2--);
      }
    }
    auto it3 = col[y].lower_bound(x);
    while (it3 != col[y].end() && v[*it3][y] != '#' && *it3 - x <= k) {
      d[*it3][y] = d[x][y] + 1;
      q.push({*it3, y});
      row[*it3].erase(y);
      col[y].erase(it3++);
    }
    auto it4 = col[y].lower_bound(x);
    if (it4 != col[y].begin()) {
      it4 = prev(it4);
      while (v[*it4][y] != '#' && x - *it4 <= k) {
        d[*it4][y] = d[x][y] + 1;
        q.push({*it4, y});
        row[*it4].erase(y);
        if (it4 == col[y].begin()) {
          col[y].erase(it4);
          break;
        } else
          col[y].erase(it4--);
      }
    }
  }
  if (d[xe][ye] == 1000000000000000000)
    cout << "-1";
  else
    cout << d[xe][ye];
}
