#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<deque>
#include<sstream>
#include<fstream>
#include<istream>
#include<random>
#include<numeric>
#include<utility>
#include<conio.h>
#include <bitset>
#include <climits>
#define       IO 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ld long double
#define endl "\n"
#define lop(i, j, n)	for(int i = j; i<n; i++)
#define prl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x)	((1ll)*(x.size()))
#define srt(x) sort(x.begin(),x.end())
#define BSearch(x,val) binary_search(x.begin(),x.end(),val)
#define pri pair<int,int>
#define EPS 1e-4
#define vll vector<ll>
#define vii vector<int>
#define PI atan(1.0)*4.0
#define sc(x) scanf("%d",&x)
#define infl	1e10
using namespace std;
vii Graph[100000+5];
//char Graph[1000][1000];
int visited[100000+5];
int dx[] = { 0 , 0 ,-1 , 1 };
int dy[] = { -1 , 1 , 0 , 0};
//ll BFS(int x) {
//	queue<int> q;
//	q.push(1);
//	memset(visited, -1, sizeof visited);
//	visited[1] = 0;
//	while (!q.empty())	{
//		int t = q.front();		
//		q.pop();		
//		if (t == n)return visited[n];
//		lop(i, 1, n + 1) {
//			if (visited[i] == -1 && Graph[t][i] == x) {
//				visited[i] = visited[t] + 1;
//				q.push(i);
//			}
//		}
//	}
//	return -1;
//}
ll binlow(ll key, vector<pair<ll, ll>>& dg) {
	ll n = dg.size() - 1, L = 1, R = n, mid, endindx = -1;
	while (L <= R) {
		mid = (R - L) / 2 + L;
		if (dg[mid].first > key) {
			R = mid - 1;
		}
		else if (dg[mid].first == key) {
			L = mid + 1;
			endindx = mid;
		}
		else if (dg[mid].first < key) {
			L = mid + 1;
			endindx = mid;
		}
	}
	return endindx;
}
string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll GCD(ll a, ll b) { return((!b) ? a : GCD(b, a%b)); }
ll LCM(ll a, ll b) { return a / (GCD(a, b))*b; }
ll nCr(ll n, ll r) { if (n < r)return 0; if (r == 0)return 1; return n*nCr(n - 1, r - 1) / r; }
ll toDecimal(vll& a, int base, int siz) { ll ans = 0;	for (ll i = siz - 1, x = 1; i >= 0; i--, x *= base) { ans += (a[i] * x); } return ans; }
bool isPrime(ll n) { if (n == 2)return 1; if (n < 2 || n % 2 == 0)return 0; for (ll i = 3; i*i <= n; i += 2)if (n%i == 0)return 0; return 1; }
bool isPalindrome(string str) { ll l = 0; ll h = sz(str) - 1; while (h > l) { if (str[l++] != str[h--]) { return 0; } } return 1; }
bool isEqual(string x, string y) { if (sz(x) != sz(y))return 0; lop(i, 0, sz(x)) { if (x[i] != y[i])return 0; } return 1; }
ll n, m, q,T,k;
ll dp[100000 + 5][30];




int main() {
	IO;
	//freopen("lucky.in", "r", stdin);
	//freopen("key.out", "w", stdout);
	cin >> T;
	while (T--) {
		ll a, b, c, ans = 0;
		cin >> a >> b >> c;
		//if (!b) { cout << 0 << endl; continue; }
		ll mx = max(a, max(b, c));
		if (mx == a) {
			while (b >= 2 && a >= 1)
			{
				ans += 3;
				b -= 2, a--;
			}
			while (c >= 2 && b >= 1)
			{
				ans += 3;
				c -= 2, b--;
			}
			cout << ans << endl;
		}
		else if (mx == b) {
			if (c > a) {
				while (c >= 2 && b >= 1)
				{
					ans += 3;
					c -= 2, b--;
				}
				while (b >= 2 && a >= 1)
				{
					ans += 3;
					b -= 2, a--;
				}
				cout << ans << endl;
			}
			else {
				while (b >= 2 && a >= 1)
				{
					ans += 3;
					b -= 2, a--;
				}
				while (c >= 2 && b >= 1)
				{
					ans += 3;
					c -= 2, b--;
				}
				cout << ans << endl;
			}
		}
		else {
			while (c>=2 && b >= 1)
			{
				ans += 3;
				c -= 2, b--;
			}
			while (b>=2 && a >= 1)
			{
				ans += 3;
				b -= 2, a--;
			}
			cout << ans << endl;
		}
	}
	
//	system("pause");
	return 0;
}