for i in range(int(input())):
	a, b, c = map(int, input().split())
	ans = 0
	for x in range(a+1):
		for y in range(b+1):
			if(2*x + y <= b and 2*y <= c):
				ans = max(ans, 3*(x+y))
	print(ans)

# n, m = map(int, input().split())
# k = 10**9 + 7
# a = (pow(2, m, k) - 1)%k
# ans = pow(a, n, k)
# print(ans)