#include #include #define sc(x) scanf("%d",&x) using namespace std; int n, ans, b[12][12]; char a[12][12]; bool vis; void dfs(int x, int y) { if (x == n && y == n) { a[n][n] = '.'; ans++; vis = true; return; } if (y + 1 <= n && a[x][y + 1] != '#') { a[x][y + 1] = '#'; dfs(x, y + 1); if (vis && (x > 1 || y > 1))return; a[x][y + 1] = '.'; } if (x + 1 <= n && a[x + 1][y] != '#') { a[x + 1][y] = '#'; dfs(x + 1, y); if (vis && (x > 1 || y > 1))return; a[x + 1][y] = '.'; } vis = false; return; } int main(void) { int t; sc(t); while (t--) { sc(n); getchar(); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { a[i][j] = getchar(); b[i][j] = 0; if (i == 1 || j == 1 && a[i][j] == '.')b[i][j] = 1; } getchar(); } if (a[1][1] == '#' || a[n][n] == '#') { puts("0"); continue; } ans = 0; vis = false; dfs(1, 1); cout << ans << endl; } return 0; }