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