#include #include #include #include #define x first #define y second using namespace std; const int N = 15; char g[N][N]; int n; bool dfs(int x,int y) { if(x==n&&y==n) { return true; } if(y+1<=n&&g[x][y+1]=='.') { if(!(x==n&&y+1==n)) { g[x][y+1]='#'; } if(dfs(x,y+1))return true; } if(x+1<=n&&g[x+1][y]=='.') { if(!(x+1==n&&y==n)) { g[x+1][y]='#'; } if(dfs(x+1,y))return true; } return false; } int main() { int T; scanf("%d", &T); while(T--) { scanf("%d", &n); for (int i = 1; i <= n; i ++ )scanf("%s",g[i]+1); if(g[1][1]=='#') { printf("0"); puts(""); //if(T!=0)puts(""); continue; } int res=0; if(g[1][2]=='.') { if(dfs(1,2))res++; } if(g[2][1]=='.') { if(dfs(2,1))res++; } printf("%d",res); puts(""); //if(T!=0)puts(""); } return 0; }