input = __import__("sys").stdin.readline
for _ in xrange(int(input())):
	a, b, c = map(int, input().split())
	out = 0
	while b and c > 1:
		out += 3
		b -= 1
		c -= 2
	while a and b > 1:
		out += 3
		a -= 1
		b -= 2
	print(out)