n=int(input())
for i in range(n):
	ai,bi,ci=map(int,input().split())
	if 2*bi<=ci:
		print(3*bi)
	elif bi==0:
		print("0")
	else:
		y=bi-int(ci/2)
		if 2*ai<=y:
			print(3*(ai+int(ci/2)))
		else:
			print(3*(int(ci/2)+int(y/2)))
