dp[w][i][j][k]表示左上角坐标为(i,j,k)大小为w的cube的最大值
状态转移:dp[w+1][i][j][k]=max(dp[w][i+a][j+b][k+c]) a,b,c={0,1}
def specialSubCubes(n,a):
cube=[[[0 for _ in range(n)] for _ in range(n)] for _ in range(n)]
p=0
for i in range(n):
for j in range(n):
for k in range(n):
cube[i][j][k]=a[p]
p+=1
dp=[[[[0 for _ in range(n)] for _ in range(n)] for _ in range(n)] for _ in range(n)]
dp[0]=cube
res=[0]*n
res[0]=a.count(1)
for w in range(1,n):
for i in range(n-w):
for j in range(n-w):
for k in range(n-w):
t=[dp[w-1][i][j][k], dp[w-1][i][j][k+1], dp[w-1][i][j+1][k], dp[w-1][i][j+1][k+1],
dp[w-1][i+1][j][k], dp[w-1][i+1][j][k+1], dp[w-1][i+1][j+1][k], dp[w-1][i+1][j+1][k+1]]
dp[w][i][j][k]=max(t)
if dp[w][i][j][k]==w+1: res[w]+=1
# print(dp)
return res
if __name__ == '__main__':
q = int(input())
for q_itr in range(q):
n = int(input())
cube = list(map(int, input().rstrip().split()))
result = specialSubCubes(n,cube)
print(' '.join(list(map(str,result))))