import sys
from functools import lru_cache

@lru_cache(maxsize=None)
def solve(a,b,c):
	res = 0
	if (a >= 1) and (b >= 2):
		res = max(res,3+solve(a-1,b-2,c))
	if (b >= 1) and (c >= 2):
		res = max(res,3+solve(a,b-1,c-2))
	return res

sys.setrecursionlimit(9001)
for _ in range(int(input())):
	arr = [int(x) for x in input().split()]
	print(solve(arr[0],arr[1],arr[2]))
