MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
from math import *

t, = I()
while t:
	t -= 1
	a, b, c = I()
	ans = 0
	while b > 0:
		if c > 1:
			ans += 3
			b -= 1
			c -= 2
		elif b >= 2 and a:
			ans += 3
			a -= 1
			b -= 2
		else: break
	print(ans)