#include<stdiio.h>
int main()
{
int t,n,i,x,y,s,l;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int a[n*n],b[n];
for(i=0;i<n*n;i++)
scanf("%d",&a[i]);
for(x=0;x<=n;x++)
{
s=y=0;
while(y<=n)
{
s+=a[x+y];
y+=(n-1);
}
b[x]=s;
}
for(i=0;i<n;i++)
printf("%d ",b[i]);
printf("\n");
}
return 0;
}
Input Sample:-
1.Number of Test Case
2.n – an integer
3.n*n integers
Output Format:-
Three integers separated by space
Sample Input:-
2
3
1 2 3 4 5 6 7 8 9
4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output:-
12 15 18
28 32 36 40