/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
{
Scanner sc
=new Scanner
(System.
in); int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int mat[][]=new int[n][n];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
mat[i][j]=sc.nextInt();
}
}
int sub[]=new int[2*n-1];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
sub
[i
-j
+n
-1]=Math.
min(sub
[i
-j
+n
-1],mat
[i
][j
]); }
}
int ans=0;
for(int i=0;i<n;i++){
if(sub[i]<0){
ans-=sub[i];
}
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgTWFpbgp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlTY2FubmVyIHNjPW5ldyBTY2FubmVyKFN5c3RlbS5pbik7CgkJaW50IHQ9c2MubmV4dEludCgpOwoJCXdoaWxlKHQtLT4wKXsKCQkJaW50IG49c2MubmV4dEludCgpOwoJCQlpbnQgbWF0W11bXT1uZXcgaW50W25dW25dOwoJCQlmb3IoaW50IGk9MDtpPG47aSsrKXsKCQkJCWZvcihpbnQgaj0wO2o8bjtqKyspewoJCQkJCW1hdFtpXVtqXT1zYy5uZXh0SW50KCk7CgkJCQl9CgkJCX0KCQkJaW50IHN1YltdPW5ldyBpbnRbMipuLTFdOwoJCQlmb3IoaW50IGk9MDtpPG47aSsrKXsKCQkJCWZv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