#include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; typedef long long ll; #define rep(i,n) for (int i = 0; i < int(n);i++) int main(){ int t; cin >> t; while(t--){ ll a,b,c; cin >> a >> b >> c; ll ans = 0; ll d = min(a,c); ans += d*2; c -= d; a -= d; ans += 2*(b/2); b%=2; ans += (c/2); c%=2; if (a == 1 && b == 1) ans++; cout << ans << endl; } return 0; }