#include using namespace std; using ll = long long; const long long INF = 1LL<<60; int main() { int t; cin >> t; while(t--) { long long a, b, c; cin >> a >> b >> c; long long ans = 0; ans += b / 2 * 2; b = b % 2; long long d = min(a, c); ans += d * 2; a -= d; c -= d; long long e = min(a, b); ans += e; cout << ans << endl; } }