#include using namespace std; int n; char c; int ans[15][15]; int a[2] = {0 , 1}; int b[2] = {1 , 0}; bool dfs(int i , int j){ if(i == n && j == n) return true; ans[i][j] = 0; for(int x = 0;x < 2;x ++){ int p = i + a[x] , q = j + b[x]; if(p >= 1 && q >= 1 && p <= n && q <= n && ans[p][q]){ if(dfs(p , q)) return true; } } ans[i][j] = 1; return false; } signed main(void){ int t; cin >> t; while(t --){ memset(ans , 0 , sizeof(ans)); cin >> n; getchar(); int i = 1; while(i <= n){ int j = 1; c = getchar(); while(c == '.' || c == '#'){ if(c == '.') ans[i][j ++] = true; else ans[i][j ++] = false; c = getchar(); } i ++; } bool x = 0 , y = 0; if(ans[1][1]){ x = dfs(1 , 1); y = dfs(1 , 1); } cout << x + y << endl; } return 0; }