entries = int(input())
for i in range(entries):
	a, b, c = map(int, input().split())
	total = 0
	while c >= 2 and b >= 1:
		total += 3
		b -= 1
		c -= 2
	while b >= 2 and a >= 1:
		total += 3
		b -= 2
		a -= 1
	print(total)
 	 	  			 	 	 			    		 	     	