#include using namespace std; const int MaxN = 1e5 + 10; const int MOD = 1e9 + 7; const int INF = 1e9; int main() { // freopen("input.txt", "r", stdin); int t; scanf("%d", &t); assert (1 <= t && t <= 10000); for (int it = 1; it <= t; ++it) { int mat[3][3]; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { int x; scanf("%d", &x); assert (0 <= x && x <= INF); mat[i][j] = x; } } long long ans = 0; for (int mask = 0; mask < 8; ++mask) { for (int i = 0; i < 3; ++i) { long long cur = 0; for (int j = 0; j < 3; ++j) { if (mask & (1 << j)) { cur += mat[i][j]; } } if (cur & 1) { ans = max(ans, cur); } else { ans = max(ans, cur - 1); } } for (int i = 0; i < 3; ++i) { long long cur = 0; for (int j = 0; j < 3; ++j) { if (mask & (1 << j)) { cur += mat[j][i]; } } if (cur & 1) { ans = max(ans, cur); } else { ans = max(ans, cur - 1); } } } cout << ans << '\n'; } return 0; }