#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <fstream>
#include <cassert>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define sz(a) int((a).size())
#define rep(i, s, n) for(int i = s; i <= (n); ++i)
#define rev(i, n, s) for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 100005;
const ll inf = mod * 1LL * mod;
ll a[21][21][21];
int main() {
#ifdef loc
if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
assert(0);
}
freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
boost;
int t;
cin >> t;
while (t-- > 0) {
memset(a, 0, sizeof(a));
int l, n, m;
cin >> l >> n >> m;
ll mx = -inf;
rep(i, 1, l) {
rep(j, 1, n) {
rep(k, 1, m) {
cin >> a[i][j][k];
mx = max(mx, a[i][j][k]);
a[i][j][k] += a[i][j - 1][k];
a[i][j][k] += a[i][j][k - 1];
a[i][j][k] -= a[i][j - 1][k - 1];
}
}
}
if (mx < 0) {
cout << mx << endl;
if (t > 0) cout << endl;
continue;
}
ll ans = 0;
rep(i1, 1, n) {
rep(j1, 1, m) {
rep(i2, i1, n) {
rep(j2, j1, m) {
ll cur = 0;
rep(k, 1, l) {
ll p = a[k][i2][j2] - a[k][i1 - 1][j2] - a[k][i2][j1 - 1] + a[k][i1 - 1][j1 - 1];
cur = max(0LL, cur + p);
ans = max(ans, cur);
}
}
}
}
}
cout << ans << endl;
if (t > 0) cout << endl;
}
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGxpc3Q+Ci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KY29uc3QgaW50IE4gPSAxMDAwMDU7CmNvbnN0IGxsIGluZiA9IG1vZCAqIDFMTCAqIG1vZDsKCmxsIGFbMjFdWzIxXVsyMV07CgppbnQgbWFpbigpIHsKI2lmZGVmIGxvYwogIGlmKCFmcmVvcGVuKChzdHJpbmcoRk9MREVSKSArICJpbnAudHh0IikuY19zdHIoKSwgInIiLCBzdGRpbikpIHsKICAgIGFzc2VydCgwKTsKICB9CiAgZnJlb3Blbigoc3RyaW5nKEZPTERFUikgKyAib3V0LnR4dCIpLmNfc3RyKCksICJ3Iiwgc3Rkb3V0KTsKI2VuZGlmCiAgYm9vc3Q7CiAgaW50IHQ7CiAgY2luID4+IHQ7CiAgd2hpbGUgKHQtLSA+IDApIHsKICAgIG1lbXNldChhLCAwLCBzaXplb2YoYSkpOwogICAgaW50IGwsIG4sIG07CiAgICBjaW4gPj4gbCA+PiBuID4+IG07CiAgICBsbCBteCA9IC1pbmY7CiAgICByZXAoaSwgMSwgbCkgewogICAgICByZXAoaiwgMSwgbikgewogICAgICAgIHJlcChrLCAxLCBtKSB7CiAgICAgICAgICBjaW4gPj4gYVtpXVtqXVtrXTsKICAgICAgICAgIG14ID0gbWF4KG14LCBhW2ldW2pdW2tdKTsKICAgICAgICAgIGFbaV1bal1ba10gKz0gYVtpXVtqIC0gMV1ba107CiAgICAgICAgICBhW2ldW2pdW2tdICs9IGFbaV1bal1bayAtIDFdOwogICAgICAgICAgYVtpXVtqXVtrXSAtPSBhW2ldW2ogLSAxXVtrIC0gMV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBpZiAobXggPCAwKSB7CiAgICAgIGNvdXQgPDwgbXggPDwgZW5kbDsKICAgICAgaWYgKHQgPiAwKSBjb3V0IDw8IGVuZGw7CiAgICAgIGNvbnRpbnVlOwogICAgfQogICAgbGwgYW5zID0gMDsKICAgIHJlcChpMSwgMSwgbikgewogICAgICByZXAoajEsIDEsIG0pIHsKICAgICAgICByZXAoaTIsIGkxLCBuKSB7CiAgICAgICAgICByZXAoajIsIGoxLCBtKSB7CiAgICAgICAgICAgIGxsIGN1ciA9IDA7CiAgICAgICAgICAgIHJlcChrLCAxLCBsKSB7CiAgICAgICAgICAgICAgbGwgcCA9IGFba11baTJdW2oyXSAtIGFba11baTEgLSAxXVtqMl0gLSBhW2tdW2kyXVtqMSAtIDFdICsgYVtrXVtpMSAtIDFdW2oxIC0gMV07CiAgICAgICAgICAgICAgY3VyID0gbWF4KDBMTCwgY3VyICsgcCk7CiAgICAgICAgICAgICAgYW5zID0gbWF4KGFucywgY3VyKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogICAgY291dCA8PCBhbnMgPDwgZW5kbDsKICAgIGlmICh0ID4gMCkgY291dCA8PCBlbmRsOwogIH0KICByZXR1cm4gMDsKfQ==