for i in range(int(input())):
	a, b, c = list(map(int, input().split()))

	stones = 0
	while c > 1 and b > 0:
		stones += 3
		c -= 2
		b -= 1
	while a > 0 and b > 1:
		stones += 3
		a -= 1
		b -= 2
	print(stones)