#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; #define int long long const int maxn = 2e6 + 7; const int INF = (1 << 31) - 1; const int mod = 1e9 + 7; const double PI = acos(-1); inline ll ksm(ll a, ll p) { ll res = 1; while (p) { if (p & 1)res *= a; a *= a; p >>= 1; }return res; } char mp[17][17]; ll cnt, n; bool vis[17][17]; bool dfs(int i, int j) { if (i > n || j > n || mp[i][j] != '.')return 0; if (i == n && j == n) { ++cnt; return 1; } if (vis[i][j])return 0; vis[i][j] = 1; if (i == 1 && j == 1)vis[i][j] = 0; if (dfs(i + 1, j))return 1; if (dfs(i, j + 1))return 1; return 0; } void work() { cin >> n; memset(vis, 0, sizeof vis); for (int i = 1; i <= n; ++i)for (int j = 1; j <= n; ++j)cin >> mp[i][j]; cnt = 0; while (dfs(1, 1)); cout << cnt << '\n'; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T; cin >> T; for (int i = 1; i <= T; ++i) { //cout << "Case #" << i << ": "; work(); } }