#include <bits/stdc++.h>
#include <stdio.h>

#define __Shibae__      signed main()
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fiopen(Path)    freopen(Path".INP", "r", stdin); freopen(Path".OUT", "w", stdout);
#define fipen(Path)     freopen(Path".INP", "r", stdin);
#define sz(s)           (int)s.size()
#define all(x)          x.begin(), x.end()
#define maxHeap         priority_queue<int>
#define minHeap         priority_queue<int, vector<int>, greater<int>>
#define getBit(x, k)    (((x) >> (k)) & 1)
#define MASK(i)         (1LL << (i))
#define SQR(x)          (1LL * ((x) * (x)))
#define db              double
#define ld              long double
#define ui              unsigned int
#define ll              long long
#define ii              pair<int, int>
#define pli             pair<ll, int>
#define pil             pair<int, ll>
#define pll             pair<ll, ll>
#define fi              first
#define se              second

#define FOR(i, a, b)    for(int i = a, _b = b; i <= _b; i += 1)
#define FOD(i, a, b)    for(int i = a, _b = b; i >= _b; i -= 1)
#define REP(i, a)       for(int i = 0, _a = a; i < _a; i++)
#define pb              push_back
#define fau(u, a)       for(auto &u : a)

using namespace std;

const ll mod = 1e9 + 7;
const int INF = 1e9 + 7;
const ll INFLL = (ll)2e18 + 7LL;
const ld PI = acos(-1);
const int MAX = 2210;
 
const int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};

mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());

ll Rand(ll l, ll r) 
{
    return l + rd() % (r - l + 1);
}

template<class SHIBA, class ENGINE>
    bool minimize(SHIBA &x, const ENGINE y)
    {
        if(x > y)
        {
            x = y;
            return true;
        } 
        else return false;
    }
template<class SHIBA, class ENGINE>
    bool maximize(SHIBA &x, const ENGINE y)
    {
        if(x < y)
        {
            x = y;
            return true;
        }
        else return false;
    }


/* Template by: Nguyen Nhat Anh from Luong Van Chanh High School for the gifted */
/* From Min Tuoi with love */
        /**       TRY HARD        **/
        /**          ORZ          **/

/* -----------------[ MAIN CODE ]----------------- */

int n, m, k;
int a[MAX][MAX];
int f[4][MAX][MAX];
int xs, ys, xt, yt; 

int get(int x)
{
    return x / k + (x % k != 0);
}

struct owo
{
    int x, y, direct, rlen, len;

    bool operator < (const owo &b) const
    {
        return rlen + get(len) > b.rlen + get(b.len);
    }
};

void input()
{
    cin >> n >> m >> k;

    FOR(i, 1, n) FOR(j, 1, m)
    {
        char c; cin >> c;
        a[i][j] = (c == '.' ? 1 : -1);
        f[0][i][j] = f[1][i][j] = f[2][i][j] = f[3][i][j] = INF;
    }

    cin >> xs >> ys >> xt >> yt;
}

bool inside(int u, int v)
{
    return u >= 1 && u <= n && v >= 1 && v <= m;
}

void dijk()
{
    priority_queue<owo> pq;

    f[0][xs][ys] = f[1][xs][ys] = f[2][xs][ys] = f[3][xs][ys] = 0;

    pq.push({xs, ys, 0, 0, 0});
    pq.push({xs, ys, 1, 0, 0});
    pq.push({xs, ys, 2, 0, 0});
    pq.push({xs, ys, 3, 0, 0});

    while(pq.size())
    {
        int x = pq.top().x;
        int y = pq.top().y;
        int dir = pq.top().direct;
        int rlen = pq.top().rlen;
        int len = pq.top().len;
        // cout << x << " " << y << " " << rlen + get(len) << "\n";

        pq.pop();

        if (rlen + get(len) > f[dir][x][y]) continue;
        if (x == xt && y == yt) return;

        int cur = get(len+1);
        int cc = get(len);

        REP(i, 4)
        {
            int u = x + dx[i];
            int v = y + dy[i];

            if (inside(u, v) && a[u][v] != -1)
            {
                if (i == dir)
                {
                    if (minimize(f[dir][u][v], rlen + cur))
                    {
                        pq.push({u, v, dir, rlen, len + 1});
                    }
                }
                else
                {
                    if (minimize(f[i][u][v], rlen + cc + 1))
                    {
                        pq.push({u, v, i, rlen + cc, 1});
                    }
                }
            }
        }
    }
}

void solve()
{
    if (xs == xt && ys == yt)
    {
        cout << 0;
        return;
    }

    dijk();

    int res = INF;

    REP(i, 4)
    {
        // cout << f[i][xt][yt] << " ";
        minimize(res, f[i][xt][yt]);
    }    

    cout << (res == INF ? -1 : res);
}

__Shibae__
{
    IOS
    fipen("m");

    input();
    solve();
 
    return 0;
}