#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< ll, ll >
#define piiii pair<ll,pair<ll,pii>>
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
// #define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void  solve(){
  ll h,w,k,x1,x2,y1,y2;
  char kl;

  cin>>h>>w>>k;
  cin>>x1>>y1>>x2>>y2;
  x1--,y1--,x2--,y2--;

  vector<vector<ll>> a(h,vector<ll>(w,0));
  rep(i,0,h) rep(j,0,w) {cin>>kl; if(kl=='.') a[i][j]=1;}

  vector<pii> direction ={{1,0},{0,1},{-1,0},{0,-1}};

  vector<vector<ll>> dp(h,vector<ll>(w,1e18));
  priority_queue<piiii,vector<piiii> ,greater<piiii>> pq;

  dp[x1][y1]=0;
  pii pos={x1,y1};
  if(pos.f>0 && a[pos.f-1][pos.s]==1) pq.push({1,{2,{pos.f-1,pos.s}}});
  if(pos.s>0 && a[pos.f][pos.s-1]==1) pq.push({1,{3,{pos.f,pos.s-1}}});
  if(pos.f+1<h && a[pos.f+1][pos.s]==1) pq.push({1,{0,{pos.f+1,pos.s}}});
  if(pos.s+1<w && a[pos.f][pos.s+1]==1) pq.push({1,{1,{pos.f,pos.s+1}}});
  vector<vector<vi>> vis(h,vector<vi>(w,vi(4,0)));
  while(!pq.empty()){
      piiii top=pq.top();
      pq.pop();
      pos = top.s.s;
      ll val=top.f,val1=val;
      ll dire=top.s.f;
      ll yx=ceil((val*1.0)/k);
      if(vis[pos.f][pos.s][dire]) continue;
      vis[pos.f][pos.s][dire]=1;
      if((dp[pos.f][pos.s]+k-1)/k<=val/k) continue;

      dp[pos.f][pos.s]=min(dp[pos.f][pos.s],val);

      if(pos.f>0 && a[pos.f-1][pos.s]==1) {
        val1=val;
        if(dire != 2) val1=yx*k;
        if(dp[pos.f-1][pos.s]+k>=val1+1)pq.push({val1+1,{2,{pos.f-1,pos.s}}});
      }
      if(pos.s>0 && a[pos.f][pos.s-1]==1) {
        val1=val;
        if(dire != 3) val1=yx*k;
        if(dp[pos.f][pos.s-1]+k>=val1+1)pq.push({val1+1,{3,{pos.f,pos.s-1}}});
      }
      if(pos.f+1<h && a[pos.f+1][pos.s]==1) {
        val1=val;
        if(dire != 0) val1=yx*k;
        if(dp[pos.f+1][pos.s]+k>=val1+1)pq.push({val1+1,{0,{pos.f+1,pos.s}}});
      }
      if(pos.s+1<w && a[pos.f][pos.s+1]==1) {
        val1=val;
        if(dire != 1) val1=yx*k;
        if(dp[pos.f][pos.s+1]+k>=val1+1) pq.push({val1+1,{1,{pos.f,pos.s+1}}});
      }
  }
  // cout<<dp[x2][y2]<<endl;
  if(dp[x2][y2]==1e18) cout<<-1<<endl;
  else cout<<(ll) (ceil(1.0*dp[x2][y2]/k))<<endl;
}

int n,m,k;
int sx,sy,ex,ey;
queue<pair<int,pii> >q;
void solve1(){
	cin>>n>>m>>k;
	cin>>sx>>sy>>ex>>ey;
	sx--;sy--;ex--;ey--;
	vector<string>c(n,"");
	rep(i,0,n)cin>>c[i];
	vector<vector<int> >dp(n,vector<int>(m,INF));

	q.push(make_pair(0,pii(sx,sy)));
	dp[sx][sy]=0;
	while(!q.empty()){
		int cost=q.front().first,tx=q.front().second.first,ty=q.front().second.second;
		q.pop();
		rep(i,0,4){
			int ncost=cost+1;
			int nx=tx,ny=ty;
			rep(j,0,k){
				nx+=dx[i];ny+=dy[i];
				if(nx<0||nx>=n||ny<0||ny>=m||c[nx][ny]=='@')break;
				if(dp[nx][ny]>ncost){
					dp[nx][ny]=ncost;
					q.push(make_pair(ncost,pii(nx,ny)));
				}
				else if(dp[nx][ny]==ncost)continue;
				else break;
			}
		}
	}
	if(dp[ex][ey]==INF)cout<<-1<<endl;
	else cout<<dp[ex][ey]<<endl;
	// return 0;
}

int main(){
    optimizeIO();
    // tc
    { solve1();
    }
}


Measured memory_bytes: 12188