import sys input = sys.stdin.readline R,C,T=map(int,input().split()) x,y=map(int,input().split()) z0,w0=map(int,input().split()) def prod(A,B,k,l,m):# A:k*l,B:l*m C=[[0 for i in range(m)] for j in range(k)] for i in range(k): for j in range(m): ANS=0 for pl in range(l): ANS=(ANS+A[i][pl]*B[pl][j]) C[i][j]=ANS return C def plus(A,B,k,l):# a,B:k*l C=[[0 for i in range(l)] for j in range(k)] for i in range(k): for j in range(l): C[i][j]=(A[i][j]+B[i][j]) return C B=[input().strip() for i in range(R)] A=[[0]*(R*C) for i in range(R*C)] for i in range(R): for j in range(C): fr=C*i+j if B[i][j]==".": pos=0 for z,w in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]: if 0<=z0: for z,w in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]: if 0<=z