#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int t; cin >> t; while (t--) { ll a, b, c; cin >> a >> b >> c; auto solve = [](ll a, ll b, ll c) { ll res = b + 2 * c; // ここからどれだけ減るか c = max(0LL, c - a); // 0, 2 ペア res -= 3 * (c / 2 + c % 2); // 2, 2 ペア -> 1, 2 ペア return res; }; ll ans = 0; if ((a + b + c) % 2 != 0) { if (a > 0) ans = max(ans, solve(a - 1, b, c)); if (b > 0) ans = max(ans, solve(a, b - 1, c)); if (c > 0) ans = max(ans, solve(a, b, c - 1)); } else { ans = solve(a, b, c); } cout << ans << endl; } return 0; }