#include using namespace std; int n; char a[11][11]; int ans; bool vis = true; 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(){ int t; scanf("%d", &t); while(t--){ scanf("%d", &n); ans = 0; getchar(); for (int i = 1; i <= n;i++){ for (int j = 1; j <= n; j++) { a[i][j] = getchar(); } getchar(); } if(a[1][1]=='#') cout << 0 << endl; else{ ans = 0; dfs(1, 1); cout << ans << endl; } } return 0; }