#include <bits/stdc++.h>
using namespace std;

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e12)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

void solve(int &test) {
    int n, m, k;
    cin >> n >> m >> k;
    string s[n];
    pii in, fi;
    cin >> in.first>>in.second >> fi.first>>fi.second;
    set<int> row[n], col[m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++)
            row[i].insert(j), col[j].insert(i);
        cin >> s[i];
    }
    
    
    in = in - mp((int)1, (int)1);
    fi = fi - mp((int)1, (int)1);
    int dis[n][m];
    memset(dis, -1, sizeof(dis));
    queue<pii> q;
    q.push(in);
    row[in.F].erase(in.S);
    col[in.S].erase(in.F);
    dis[in.F][in.S] = 0;
    while(!q.empty()){
        int i = q.front().F;
        int j = q.front().S;
        // cout << q.front() << endl;
        // cout << dis[i][j] << endl;
        q.pop();
        auto it = row[i].upper_bound(j);
        while(it != end(row[i]) && s[i][*it] == '.' && abs(*it-j) <= k){
            dis[i][*it] = dis[i][j]+1;
            q.push(mp(i, *it));
            col[*it].erase(i);
            row[i].erase(it);
            it = row[i].upper_bound(j);
        }
        it = col[j].upper_bound(i);
        while(it != end(col[j]) && s[*it][j] == '.' && abs(*it-i) <= k){
            dis[*it][j] = dis[i][j]+1;
            q.push(mp(*it, j));
            row[*it].erase(j);
            col[j].erase(it);
            it = col[j].upper_bound(i);
        }
        it = col[j].upper_bound(i);
        while(si(col[j]) && it != begin(col[j]) && s[*(--it)][j] == '.' && abs(*it-i) <= k){
            dis[*it][j] = dis[i][j]+1;
            q.push(mp(*it, j));
            row[*it].erase(j);
            col[j].erase(it);
            it = col[j].upper_bound(i);
        }
        it = row[i].upper_bound(j);
        while(si(row[i]) && it != begin(row[i]) && s[i][*(--it)] == '.' && abs(*it-j) <= k){
            dis[i][*it] = dis[i][j]+1;
            q.push(mp(i, *it));
            col[*it].erase(i);
            row[i].erase(it);
            it = row[i].upper_bound(j);
        }
    }
    if(dis[fi.F][fi.S] != -1){
        cout << dis[fi.F][fi.S] << endl;
    } else {
        cout << -1 << endl;
    }
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;

    start = clock(); 

    cout << fixed << setprecision(20);
    

   
    // cin >> t;
    
    for(int i = 1; i <= t; ++i){
        solve(i);
    }
    //cerr << time(start);
    return 0;
}





Measured memory_bytes: 152836