#include // iostream is too mainstream #include // bitch please #include #include #include #include #include #include #include #include #include #include #include #include #define dibs reserve #define OVER9000 1234567890 #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++) #define tisic 47 #define soclose 1e-8 #define chocolate win // so much chocolate #define patkan 9 #define ff first #define ss second #define abs(x) (((x) < 0)?-(x):(x)) #define uint unsigned int #define dbl long double #define pi 3.14159265358979323846 using namespace std; // mylittledoge using cat = long long; #ifdef DONLINE_JUDGE // palindromic tree is better than splay tree! #define lld I64d #endif int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); int T; cin >> T; for(int t = 0; t < T; t++) { int N; cin >> N; vector< vector > A(N, vector(N)); for(int i = 0; i < N*N; i++) cin >> A[i/N][i%N]; int maxsum = 0; for(int i = -N; i <= N; i++) { int sum = 0; for(int s = 0; s <= 2*N; s++) if((s+i)%2 == 0) if((s+i)/2 < N && s-i >= 0 && s+i >= 0 && (s-i)/2 < N) sum += A[(s+i)/2][(s-i)/2]; maxsum = max(maxsum, sum); } cout << maxsum << "\n"; } return 0;} // look at my code // my code is amazing