import sys
sys.setrecursionlimit(1000000) # 设置递归深度限制为 1000000
N = 110
g = [[0] * N for _ in range(N)] # 初始化二维列表 g,大小为 N*N,初始值为 0
dx = [0, 1, 0, -1] # 定义方向数组 dx,表示上、右、下、左四个方向的行变化
dy = [1, 0, -1, 0] # 定义方向数组 dy,表示上、右、下、左四个方向的列变化
def dfs(sx, sy):
if g[sx][sy] == '#': # 如果当前位置是障碍物 '#'
return False
if sx == c and sy == d: # 如果当前位置是终点 (c, d)
return True
g[sx][sy] = '#' # 将当前位置标记为已访问过
# 尝试向四个方向进行搜索
for i in range(4):
x = sx + dx[i]
y = sy + dy[i]
if 0 <= x < n and 0 <= y < n and g[x][y] == '.': # 确保新位置 (x, y) 在有效范围内且为可通行路径 '.'
if dfs(x, y): # 递归搜索下一个位置 (x, y)
return True
return False # 所有方向都尝试过后未找到路径,返回 False
T = int(input()) # 读取测试用例数
while T:
T -= 1
n = int(i