# C. Ticks

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Casimir has a rectangular piece of paper with a checkered field of size $n×m$. Initially, all cells of the field are white.

Let us denote the cell with coordinates $i$ vertically and $j$ horizontally by $\left(i,j\right)$. The upper left cell will be referred to as $\left(1,1\right)$ and the lower right cell as $\left(n,m\right)$.

Casimir draws ticks of different sizes on the field. A tick of size $d$ ($d>0$) with its center in cell $\left(i,j\right)$ is drawn as follows:

1. First, the center cell $\left(i,j\right)$ is painted black.
2. Then exactly $d$ cells on the top-left diagonally to the center and exactly $d$ cells on the top-right diagonally to the center are also painted black.
3. That is all the cells with coordinates $\left(i-h,j±h\right)$ for all $h$ between $0$ and $d$ are painted. In particular, a tick consists of $2d+1$ black cells.

An already painted cell will remain black if painted again. Below you can find an example of the $4×9$ box, with two ticks of sizes $2$ and $3$. You are given a description of a checkered field of size $n×m$. Casimir claims that this field came about after he drew some (possibly $0$) ticks on it. The ticks could be of different sizes, but the size of each tick is at least $k$ (that is, $d\ge k$ for all the ticks).

Determine whether this field can indeed be obtained by drawing some (possibly none) ticks of sizes $d\ge k$ or not.

Input

The first line contains an integer $t$ ($1\le t\le 100$) — the number test cases.

The following lines contain the descriptions of the test cases.

The first line of the test case description contains the integers $n$$m$, and $k$ ($1\le k\le n\le 10$$1\le m\le 19$) — the field size and the minimum size of the ticks that Casimir drew. The following $n$ lines describe the field: each line consists of $m$ characters either being '.' if the corresponding cell is not yet painted or '*' otherwise.

Output

Print $t$ lines, each line containing the answer to the corresponding test case. The answer to a test case should be YES if the given field can be obtained by drawing ticks of at least the given size and NO otherwise.

You may print every letter in any case you want (so, for example, the strings yEsyesYes, and YES will all be recognized as positive answers).

Example
input
Copy
8
2 3 1
*.*
...
4 9 2
*.*.*...*
.*.*...*.
..*.*.*..
.....*...
4 4 1
*.*.
****
.**.
....
5 5 1
.....
*...*
.*.*.
..*.*
...*.
5 5 2
.....
*...*
.*.*.
..*.*
...*.
4 7 1
*.....*
.....*.
..*.*..
...*...
3 3 1
***
***
***
3 5 1
*...*
.***.
.**..

output
Copy
NO
YES
YES
YES
NO
NO
NO
NO

Note

The first sample test case consists of two asterisks neither of which can be independent ticks since ticks of size $0$ don't exist.

The second sample test case is already described in the statement (check the picture in the statement). This field can be obtained by drawing ticks of sizes $2$ and $3$, as shown in the figure.

The field in the third sample test case corresponds to three ticks of size $1$. Their center cells are marked with $\text{blue}$$\text{red}$ and $\text{green}$ colors:

 *.*. **$\mathbf{\text{*}}$** .**$\mathbf{\text{*}}\mathbf{\text{*}}$. ....

The field in the fourth sample test case could have been obtained by drawing two ticks of sizes $1$ and $2$. Their vertices are marked below with $\text{blue}$ and $\text{red}$ colors respectively:

 ..... *...* .*.*. ..*$\mathbf{\text{*}}$.* ...*$\mathbf{\text{*}}$.

The field in the fifth sample test case can not be obtained because $k=2$, and the last asterisk in the fourth row from the top with coordinates $\left(4,5\right)$ can only be a part of a tick of size $1$.

The field in the sixth sample test case can not be obtained because the top left asterisk $\left(1,1\right)$ can't be an independent tick, since the sizes of the ticks must be positive, and cannot be part of a tick with the center cell in the last row, since it is separated from it by a gap (a point, '.') in $\left(2,2\right)$.

In the seventh sample test case, similarly, the field can not be obtained by the described process because the asterisks with coordinates $\left(1,2\right)$ (second cell in the first row), $\left(3,1\right)$ and $\left(3,3\right)$ (leftmost and rightmost cells in the bottom) can not be parts of any ticks.

### the solution to the above problem is

#include <bits/stdc++.h>

using namespace std;

#define int            long long int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
int x = 1;
while (b)
{
if (b & 1) x *= a;
a *= a;
b >>= 1;
}
return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
const char* comma = strchr (names + 1, ',');
cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;

void solve() {

int n,m,k;
cin>>n>>m>>k;

char a[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cin>>a[i][j];
}
}

for(int i=0; i<n; i++){

for(int j=0; j<m; j++){
int cnt=0;
if(a[i][j]=='*' || a[i][j]=='t'){
int c1=j-1, c2=j+1;
int r=i-1;
while((r>=0 && c1>=0 && c2<m) && ((a[r][c1]!='.' && a[r][c2]!='.')) ){

cnt++;
r--;
c1--;
c2++;

}
}
if(cnt>=k){
a[i][j]='t';
int c1=j-1, c2=j+1;
int r=i-1;
while(cnt--){
// cout<<"IN";
a[r][c1]='t';
a[r][c2]='t';
r--;
c1--;
c2++;
// cnt--;

}
}
}
}
bool flag=true;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
// cout<<a[i][j];
if(a[i][j]=='t' || a[i][j]=='.'){
continue;
}
else{
// cout<<a[i][j]<<endl;
flag=false;
break;
}
}
// cout<<endl;
}
if(flag){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}

}

int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

clock_t z = clock();

int t = 1;
cin >> t;
while (t--) solve();

return 0;
}