query = int(input())
for _ in range(query):
	a, b, c = map(int, input().split())
	s=0
	if b==0:
		print(s)
	else:
		if c>=2*b:
			s+=(b+(2*b))
		else:
			s+=(((c//2)*2)+(c//2))
			b-=(c//2)
			if b>=2*a:
				s+=(a+(a*2))
			else:
				s+=((b//2)+((b//2)*2))
		print(s)