import sys #sys.setrecursionlimit((1<<19)-1) #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') H,W,T=map(int,input().split()) Sy,Sx=map(int,input().split()) Gy,Gx=map(int,input().split()) Sy-=1 Sx-=1 Gy-=1 Gx-=1 A=[list(map(int,input())) for i in range(H)] dp=[[0]*W for i in range(H)] dp[Sy][Sx]=1 for i in range(T): ndp=[[0]*W for i in range(H)] for j in range(H): for k in range(W): if (A[j][k]-i-1)%(A[j][k]+1): for my,mx in ((0,1),(1,0),(0,-1),(-1,0)): if 0<=my+j