t = int(input())
cnt = []
for i in range(t):
	c1 = c2 = 0
	a = [int(x) for x in input().split()]
	b = []
	for j in range(3):
		b.append(a[j])
	while a[0] > 0 and a[1] > 1:
		c1 += 3
		a[0] -= 1
		a[1] -= 2
	while a[1] > 0 and a[2] > 1:
		c1 += 3
		a[1] -= 1
		a[2] -= 2
	while b[1] > 0 and b[2] > 1:
		c2 += 3
		b[1] -= 1
		b[2] -= 2
	while b[0] > 0 and b[1] > 1:
		c2 += 3
		b[0] -= 1
		b[1] -= 2
	cnt.append(max(c1, c2))
for i in range(len(cnt)):
	print(cnt[i])
