#include using namespace std; int n,tes,fg[15][15]; char s[15][15]; int dfs1(int x,int y){ fg[x][y]=1; if(x+y==n*2-1)return 1; if(y+1<=n&&fg[x][y+1]==0&&dfs1(x,y+1))return 1; return x+1<=n&&fg[x+1][y]==0&&dfs1(x+1,y); } int dfs2(int x,int y){ fg[x][y]=1; if(x+y==n*2-1)return 1; if(x+1<=n&&fg[x+1][y]==0&&dfs1(x+1,y))return 1; return y+1<=n&&fg[x][y+1]==0&&dfs1(x,y+1); } void solve(){ scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%s",s[i]+1); if(s[n][n]=='#'||s[1][1]=='#'){puts("0");return;} for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) fg[i][j]=(s[i][j]=='#'?1:0); int ans=0; if(fg[1][2]==0&&dfs1(1,2))++ans; if(fg[2][1]==0&&dfs2(2,1))++ans; printf("%d\n",ans); } int main() { scanf("%d",&tes); while(tes--)solve(); return 0; }