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