// (c) 2020, redotter
// The grass was greener...

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#pragma comment(linker, "/stack:200000000")
#endif

#define pb push_back
#define the(a) (a).begin(), (a).end()
#define ft first
#define sd second
#define endl "\n"
#define forn(i, n) for (int i = 0; i < (n); i++)

using i64 = long long;
using i32 = int;
using f64 = long double;

template <class T> using vec = vector<T>;
using str = string; using p64 = pair<i64, i64>;
using v64 = vec<i64>; using vv64 = vec<v64>;
using s64 = set<i64>; using m64 = map<i64, i64>;
template <size_t Size1> using a64 = array<i64, Size1>;
template <size_t Size1, size_t Size2> using aa64 = array<a64<Size2>, Size1>;
template <class T> using hash_set = unordered_set<T>;
template <class T, class U> using hash_map = unordered_map<T, U>;

mt19937 gen(998244353);
const i64 inf = numeric_limits<i64>::max() / 2;

template <class T> inline i64 len(const T& a) { return (i64)(a.size()); }
inline void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
template <class T, class S>
inline bool check_min(T& a, S b) { if (a > b) return a = b, 1; return 0; }
template <class T, class S>
inline bool check_max(T& a, S b) { if (a < b) return a = b, 1; return 0; }

void read() {}
template<class T, class ...U>
void read(T& a, U& ...b) { cin >> a; read(b...); }
void print() {}
template<class T, class ...U>
void print(const T& a, const U& ...b) { cout << a << " "; print(b...); }
void println() { cout << "\n"; }
template<class T, class ...U>
void println(const T& a, const U& ...b) { cout << a << " "; println(b...); }

struct Problem {
	void files(str in, str out) {
#ifdef ONLINE_JUDGE
		freopen(in.c_str(), "r", stdin), freopen(out.c_str(), "w", stdout);
#endif
	}
	void solve(), input();
	void many() { i64 t; cin >> t; while (t--) input(), solve(); }
	void make(bool mt = 0) { if (mt) many(); else input(), solve(); }
} problem;

signed main() {
	fast();
	problem.make();
#ifdef _DEBUG
	println(); println("[finished]"); system("pause > nul");
#endif
	return 0;
}

i64 n, m, k;
p64 s, t;
vv64 a;

i64 bfs(p64 s, p64 t) {
	vec<s64> line(n), column(m);
	forn(i, n) {
		forn(j, m) {
			line[i].insert(j);
			column[j].insert(i);
		}
	}
	queue<p64> q;
	vv64 d(n, v64(m, inf));
	auto push = [&](p64 u, i64 who = 0) {
		i64 i, j; tie(i, j) = u;
		if (who >= 1) line[i].erase(j);
		if (who <= 1) column[j].erase(i);
		q.push({ i, j });
	};
	push(s, 1);
	d[s.ft][s.sd] = 0;
	while (!q.empty()) {
		p64 v = q.front();
		q.pop();
		i64 i = v.ft, j = v.sd;
		auto line_it = line[i].lower_bound(j);
		if (!line[i].empty() && line_it != line[i].begin()) {
			--line_it;
		}
		while (line_it != line[i].end()) {
			i64 j_ = *line_it;
			if (j_ < j - k || j_ >= j) break;
			if (!a[i][j_]) break;
			push({ i, j_ }, 0);
			d[i][j_] = d[i][j] + 1;
			line_it = line[i].erase(line_it);
			if (line[i].empty() || line_it == line[i].begin()) break;
			--line_it;
		}
		line_it = line[i].lower_bound(j);
		while (line_it != line[i].end()) {
			i64 j_ = *line_it;
			if (j_ > j + k) break;
			if (!a[i][j_]) break;
			push({ i, j_ }, 0);
			d[i][j_] = d[i][j] + 1;
			line_it = line[i].erase(line_it);
		}
		auto column_it = column[j].lower_bound(i);
		if (!column[j].empty() && column_it != column[j].begin()) {
			--column_it;
		}
		while (column_it != column[j].end()) {
			i64 i_ = *column_it;
			if (i_ < i - k || i_ >= i) break;
			if (!a[i_][j]) break;
			push({ i_, j }, 2);
			d[i_][j] = d[i][j] + 1;
			column_it = column[j].erase(column_it);
			if (column[j].empty() || column_it == column[j].begin()) break;
			--column_it;
		}
		column_it = column[j].lower_bound(i);
		while (column_it != column[j].end()) {
			i64 i_ = *column_it;
			if (i_ > i + k) break;
			if (!a[i_][j]) break;
			push({ i_, j }, 2);
			d[i_][j] = d[i][j] + 1;
			column_it = column[j].erase(column_it);
		}
	}
	return d[t.ft][t.sd];
}

void Problem::solve() {
	i64 ans = bfs(s, t);
	if (ans == inf) ans = -1;
	println(ans);
}

void Problem::input() {
	read(n, m, k);
	read(s.ft, s.sd, t.ft, t.sd);
	--s.ft, --s.sd, --t.ft, --t.sd;
	a.resize(n, v64(m, 0));
	forn(i, n) {
		forn(j, m) {
			char c;
			read(c);
			a[i][j] = c == '.';
		}
	}
}


Measured memory_bytes: 167172