#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ull unsigned long long
#define mod 1000000007
#define pb push_back
const int N =1005;
int n ,m,k ,sti,stj,eni,enj,vis[N][N];
char g[N][N];
int ii[4]= {0,0,1,-1};
int jj[4]= {1,-1,0,0};
int bfs()
{
queue<pair<pair<int,int>,int>>q;
q.push({{sti,stj},0});
vis[sti][stj]=1;
while(!q.empty())
{
int i= q.front().first.first;
int j= q.front().first.second;
int s= q.front().second;
q.pop();
if(i== eni && j== enj) return s;
for(int x=0;x<4;x++)
{
int chi=i,chj=j;
for(int y=0;y<k;y++)
{
chi+=ii[x],chj+=jj[x];
if(chi >0 && chi<=n && chj>0 && chj<=m &&!vis[chi][chj] && g[chi][chj]!= '#')
{
q.push({{chi,chj},s+1});
vis[chi][chj]=1;
}
else break;
}
}
}
return -1;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >>m >> k;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
cin >> g[i][j];
}
cin >> sti >> stj >> eni>>enj;
cout <<bfs();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZW5kbCAnXG4nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIG1vZCAxMDAwMDAwMDA3CiNkZWZpbmUgcGIgcHVzaF9iYWNrCmNvbnN0IGludCBOID0xMDA1OwppbnQgbiAsbSxrICxzdGksc3RqLGVuaSxlbmosdmlzW05dW05dOwpjaGFyIGdbTl1bTl07CmludCBpaVs0XT0gezAsMCwxLC0xfTsKaW50IGpqWzRdPSB7MSwtMSwwLDB9OwppbnQgYmZzKCkKewogICBxdWV1ZTxwYWlyPHBhaXI8aW50LGludD4saW50Pj5xOwogICBxLnB1c2goe3tzdGksc3RqfSwwfSk7CiAgIHZpc1tzdGldW3N0al09MTsKICAgd2hpbGUoIXEuZW1wdHkoKSkKICAgewogICAgICAgaW50IGk9IHEuZnJvbnQoKS5maXJzdC5maXJzdDsKICAgICAgIGludCBqPSBxLmZyb250KCkuZmlyc3Quc2Vjb25kOwogICAgICAgaW50IHM9IHEuZnJvbnQoKS5zZWNvbmQ7CiAgICAgICBxLnBvcCgpOwogICAgICAgaWYoaT09IGVuaSAmJiBqPT0gZW5qKSByZXR1cm4gczsKICAgICAgIGZvcihpbnQgeD0wO3g8NDt4KyspCiAgICAgICB7CiAgICAgICAgICAgaW50IGNoaT1pLGNoaj1qOwogICAgICAgICAgIGZvcihpbnQgeT0wO3k8azt5KyspCiAgICAgICAgICAgewogICAgICAgICAgICAgICBjaGkrPWlpW3hdLGNoais9ampbeF07CiAgICAgICAgICAgICAgIGlmKGNoaSA+MCAmJiBjaGk8PW4gJiYgY2hqPjAgJiYgY2hqPD1tICYmIXZpc1tjaGldW2Noal0gJiYgZ1tjaGldW2Noal0hPSAnIycpCiAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgIHEucHVzaCh7e2NoaSxjaGp9LHMrMX0pOwogICAgICAgICAgICAgICAgICAgdmlzW2NoaV1bY2hqXT0xOwogICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgIGVsc2UgYnJlYWs7CiAgICAgICAgICAgfQogICAgICAgfQogICB9CiAgIHJldHVybiAtMTsKfQppbnQgbWFpbigpCnsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGNvdXQudGllKDApOwogICAgY2luID4+IG4gPj5tID4+IGs7CiAgICBmb3IoaW50IGk9MTtpPD1uO2krKykKICAgIHsKICAgICAgICBmb3IoaW50IGo9MTtqPD1tO2orKykKICAgICAgICAgICAgY2luID4+IGdbaV1bal07CiAgICB9CiAgICBjaW4gPj4gc3RpID4+IHN0aiA+PiBlbmk+PmVuajsKICAgIGNvdXQgPDxiZnMoKTsKfQo=