h,w,k=map(int,input().split())

r,s,t,u=map(lambda x:int(x)-1,input().split())

b=[input()for _ in range(h)]

l=[[-1]*w for _ in range(h)]

l[r][s]=0

from collections import*

d=deque([(r,s)])

while d:

  x,y=d.popleft()

  if(x==t)&(y==u):exit(print(l[x][y]))

  for e,f in [[1,0],[-1,0],[0,-1],[0,1]]:

    for i in range(1,k+1):

      p,q=x+e*i,y+f*i

      if not(0<=p<h and 0<=q<w)or b[p][q]=="@":break

      if 0<=l[p][q]<=l[x][y]:break

      if l[p][q]==-1:d+=[(p,q)]

      l[p][q]=l[x][y]+1

print(-1)

h,w,k=map(int,input().split())

r,s,t,u=map(lambda x:int(x)-1,input().split())

b=[input()for _ in range(h)]

l=[[-1]*w for _ in range(h)]

l[r][s]=0

from collections import*

d=deque([(r,s)])

while d:

  x,y=d.popleft()

  if(x==t)&(y==u):exit(print(l[x][y]))

  for e,f in[[1,0],[-1,0],[0,-1],[0,1]]:

    for i in range(1,k+1):

      p,q=x+e*i,y+f*i

      if not((0<=p<h)&(0<=q<w))or b[p][q]=="@":break

      if 0<=l[p][q]<=l[x][y]:break

      if l[p][q]==-1:d+=[(p,q)];l[p][q]=l[x][y]+1

print(-1)

h, w, k = map(int, input().split())
r, s, t, u = map(lambda x: int(x) - 1, input().split())
b = [input() for _ in range(h)]
l = [[-1] * w for _ in range(h)]
l[r][s] = 0
from collections import *

d = deque([(r, s)])
while d:
    x, y = d.popleft()
    if (x == t) & (y == u):
        exit(print(l[x][y]))
    for e, f in [[1, 0], [-1, 0], [0, -1], [0, 1]]:
        for i in range(1, k + 1):
            p, q = x + e * i, y + f * i
            if not (0 <= p < h and 0 <= q < w) or b[p][q] == "@":
                break
            if 0 <= l[p][q] <= l[x][y]:
                break
            if l[p][q] == -1:
                d += [(p, q)]
            l[p][q] = l[x][y] + 1
print(-1)

h, w, k = map(int, input().split())
r, s, t, u = map(lambda x: int(x) - 1, input().split())
b = [input() for _ in range(h)]
l = [[-1] * w for _ in range(h)]
l[r][s] = 0
from collections import *

d = deque([(r, s)])
while d:
    x, y = d.popleft()
    if (x == t) & (y == u):
        exit(print(l[x][y]))
    for e, f in [[1, 0], [-1, 0], [0, -1], [0, 1]]:
        for i in range(1, k + 1):
            p, q = x + e * i, y + f * i
            if not ((0 <= p < h) & (0 <= q < w)) or b[p][q] == "@":
                break
            if 0 <= l[p][q] <= l[x][y]:
                break
            if l[p][q] == -1:
                d += [(p, q)]
                l[p][q] = l[x][y] + 1
print(-1)

-            if not (0 <= p < h and 0 <= q < w) or b[p][q] == "@": +            if not ((0 <= p < h) & (0 <= q < w)) or b[p][q] == "@": -            l[p][q] = l[x][y] + 1 +                l[p][q] = l[x][y] + 1