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