/*
首先把题目转化为 连续和转化为前缀和之差 再进行拓扑排序 就能得出正确答案。
*/
#include<cstdio>
#include<cstring>#define M 110
int c[M],G[M][M];
int topo[M],t,n,sign;
bool dfs(int u)
{
//printf("%d.",u);
c[u] = -1;
for(int v = 0; v <= n; v++)
if(G[u][v])
{
if(c[v]<0) return false;
else if(!c[v]&&!dfs(v)) return false;
}
c[u] = 1;
if(!u) sign = t-1;
topo[--t] = u;
return true;
}
bool toposort()
{
t = n+1;
memset(c,0,sizeof(c));
memset(topo,0,sizeof(topo));
for(int u = 0; u <= n; u++)
if(!c[u])
if(!dfs(u)) return false;
return true;
}
int main()
{
int tc;
char c;
scanf("%d",&tc);
while(tc--)
{
memset(G,0,sizeof(G));
scanf("%d",&n);
getchar();
for(int i = 1; i <= n; i++)
for(int j = i; j <= n; j++)
{
scanf("%c",&c);
if(c=='+') G[i-1][j] = 1;
if(c=='-') G[j][i-1] = 1;
}
toposort();
int b[M];
memset(b,0,sizeof(b));
b[0] = 0;
for(int i = sign+1; i < n+1; i++)
{
int t1 = topo[i];
int t2 = topo[i-1];
if(!G[t2][t1])
b[t1] = b[t2];
else
b[t1] = b[t2]+1;
}
for(int i = sign-1; i >= 0; i--)
{
int t1 = topo[i];
int t2 = topo[i+1];
if(!G[t1][t2])
b[t1] = b[t2];
else
b[t1] = b[t2]-1;
}
for(int i = 1; i < n; i++)
printf("%d ",b[i]-b[i-1]);
printf("%d\n",b[n]-b[n-1]);
}
return 0;
}