for _ in range(int(input())):
	a,b,c = list(map(int, input().split()))
	# arr = list(map(int, input().split()))
	# n = int(input())
	cnt = 0
	c = c//2
	cnt += min(b,c)*3
	b = (b - min(c,b))//2
	cnt += min(b,a)*3
	print(cnt)