import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int,minp().split())

for t in range(mint()):
	a, b, c = mints()
	e = min(a, b//2)
	f = min(b, c//2)
	g = min(b - e*2, c//2)
	h = min(a, (b - f)//2)
	print(max(e+g,f+h)*3)
