for _ in range(int(input())):
	a,b,c = list(map(int,input().split()))
	s = 0
	if b == 0:
		print(0)
		continue
	if b > 0 and c > 1:
		while b > 0 and c > 1:
			b-=1
			s+=1
			c-=2
			s+=2
	if a > 0 and b > 1:
		while a > 0 and b > 1:
			a-=1
			s+=1
			b-=2
			s+=2
	print(s)
