t = int(input())
for i in range(0, t, 1):
	a, b, c = map(int, input().split())
	r = 0
	for j in range(0, 100, 1):
		aa = min(j, a, b // 2)
		bb = min(b - aa*2, c // 2)
		#print("aa = ", aa, ", bb = ", bb)
		r = max(r, aa * 3 + bb * 3)
	print(r)