int k, n; PII start, final; char g[N][N]; bool st[N][N];
boolbfs() { int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0};
queue<PII> q; q.push(start);
memset(st, false, sizeof st); while(!q.empty()) { auto t = q.front(); q.pop();
if (g[t.x][t.y] == '#') continue; if (t == final) returntrue; if (st[t.x][t.y]) continue; st[t.x][t.y] = true; for (int i = 0; i < 4; ++i) { int x = t.x + dx[i], y = t.y + dy[i]; if (x < 0 || y < 0 || x >= n || y >= n) continue; q.push({x, y}); } }
returnfalse; }
intmain() { cin >> k; while(k --) { cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> g[i][j]; } }