1 #include<iostream>
2 #include<cstdio>
3 #include<cstdlib>
4 using namespace std;
5 const int N=17;
6 char a[N][N];
7 int z;
8 int heng[5]={0,+1,-1,0,0};
9 int zong[5]={0,0,0,-1,+1};
10 int vis[N][N];
11 int n;
12 int ans;
13 void dfs(int x,int y)
14 {
15 if(x==n&&y==n)
16 {
17 ans=1;
18 return ;
19 }
20 for(int i=1;i<=4;i++)
21 {
22 int xx=x+heng[i];
23 int yy=y+zong[i];
24 if(xx>0&&xx<=n&&yy>0&&yy<=n&&vis[xx][yy]==0&&a[xx][yy]!='#')
25 {
26 vis[xx][yy]=1;
27 dfs(xx,yy);
28 }
29 }
30 }
31 int main()
32 {
33 cin>>z;
34 for(int k=1;k<=z;k++)
35 {
36 cin>>n;
37 for(int i=1;i<=n;i++)
38 {
39 for(int j=1;j<=n;j++)
40 {
41 cin>>a[i][j];
42 }
43 }
44 dfs(1,1);
45 if(ans==1)
46 {
47 cout<<"YES";
48 }
49 else
50 {
51 cout<<"NO";
52 }
53 }
54 return 0;
55 }