for _ in range(int(input())) :
	a,b,c = map(int,input().split())
	x=a
	y=b
	z=c
	while(1) :
		if c==0 or c==1 or b==0:
			break
		c = c - 2
		b = b -1
	while(1) :
		if b==0 or b==1 or a==0:
			break
		b = b - 2
		a = a -1
	print((x-c)+(y-b)+(z-a))