n = int(input())

count = [0 for i in range(n)]
for i in range(0,n):
	
	s = input()
	s = s.split(" ")
	a = int(s[0])
	b = int(s[1])
	c = int(s[2])
	while b > 0 and c >= 2:
		b = b - 1
		c = c - 2
		count[i] = count[i] + 3

	while a > 0 and b >= 2:
		a = a - 1
		b = b - 2
		count[i] = count[i] + 3

for i in range(0,n):
	print(count[i])


