//bfs用vis[i][x][y][k] 表示从i的方向到x,y且剩下的转弯数是k
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
const int maxn = 110 ;
int vis[4][maxn][maxn][maxn] ;
char map[maxn][maxn] ;
struct node
{
int k ;
int pre ;
int x , y;
};
int dx[4] = {0,1,0,-1} ;
int dy[4] = {-1,0,1,0} ;
int st_x , st_y ;
int en_x , en_y ;
int m ,n ; int k;
int bfs()
{
queue<struct node> que ;
memset(vis , 0 , sizeof(vis)) ;
struct node first = {k , -1 , st_x ,st_y} ;
que.push(first) ;
for(int i = 0;i < 4;i++)
vis[i][k][st_x][st_y] = 1;
while(que.size())
{
struct node now = que.front() ;
que.pop();
if(now.x == en_x && now.y == en_y && now.k >= 0)
{
printf("yes\n") ;
return 1;
}
for(int i = 0;i < 4;i++)
{
struct node next ;
next.x = now.x + dx[i] ;
next.y = now.y + dy[i] ;
if(next.x > m || next.x < 1 || next.y > n ||next.y < 1 || map[next.x][next.y] == '*')
continue ;
next.k = now.k ;
next.pre = i ;
if(now.pre != -1 && now.pre != i)
{
next.k-- ;
if(next.k < 0)
continue;
}
if(vis[i][next.k][next.x][next.y])
continue ;
que.push(next) ;
vis[i][next.k][next.x][next.y] = 1 ;
}
}
printf("no\n");
return 0;
}
int main()
{
int T ;
// freopen("in.txt","r",stdin) ;
scanf("%d" , &T) ;
while(T--)
{
scanf("%d%d" ,&m ,&n) ;
for(int i = 1;i <= m;i++)
scanf("%s",&map[i][1]) ;
scanf("%d%d%d%d%d" ,&k, &st_y , &st_x ,&en_y ,&en_x) ;
bfs() ;
}
return 0 ;
}
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
const int maxn = 110 ;
int vis[4][maxn][maxn][maxn] ;
char map[maxn][maxn] ;
struct node
{
int k ;
int pre ;
int x , y;
};
int dx[4] = {0,1,0,-1} ;
int dy[4] = {-1,0,1,0} ;
int st_x , st_y ;
int en_x , en_y ;
int m ,n ; int k;
int bfs()
{
queue<struct node> que ;
memset(vis , 0 , sizeof(vis)) ;
struct node first = {k , -1 , st_x ,st_y} ;
que.push(first) ;
for(int i = 0;i < 4;i++)
vis[i][k][st_x][st_y] = 1;
while(que.size())
{
struct node now = que.front() ;
que.pop();
if(now.x == en_x && now.y == en_y && now.k >= 0)
{
printf("yes\n") ;
return 1;
}
for(int i = 0;i < 4;i++)
{
struct node next ;
next.x = now.x + dx[i] ;
next.y = now.y + dy[i] ;
if(next.x > m || next.x < 1 || next.y > n ||next.y < 1 || map[next.x][next.y] == '*')
continue ;
next.k = now.k ;
next.pre = i ;
if(now.pre != -1 && now.pre != i)
{
next.k-- ;
if(next.k < 0)
continue;
}
if(vis[i][next.k][next.x][next.y])
continue ;
que.push(next) ;
vis[i][next.k][next.x][next.y] = 1 ;
}
}
printf("no\n");
return 0;
}
int main()
{
int T ;
// freopen("in.txt","r",stdin) ;
scanf("%d" , &T) ;
while(T--)
{
scanf("%d%d" ,&m ,&n) ;
for(int i = 1;i <= m;i++)
scanf("%s",&map[i][1]) ;
scanf("%d%d%d%d%d" ,&k, &st_y , &st_x ,&en_y ,&en_x) ;
bfs() ;
}
return 0 ;
}