import sys

sys.setrecursionlimit(pow(10, 9))

t = int(input())

for _ in range(t):
	a, b, c = map(int, input().split())
	mn = min(c//2, b)
	res = 3*mn 
	b -= mn 
	mn = min(a, b//2)
	res += 3*mn 
	print(res)
