def main ():
    ans = 0
    a, b, c = map(int, input().split())
    q, w, e = a, b, c
    f1 = 0
    f2 = 0
    while b > 0 and c > 1:
    	b -= 1
    	c -= 2
    	f1 += 3
    while a > 0 and b > 1:
    	a -= 1
    	b -= 2
    	f1 += 3
    while q > 0 and w > 1:
    	q -= 1
    	w -= 2
    	f2 += 3
    while w > 0 and e > 1:
    	w -= 1
    	e -= 2
    	f2 += 3

    ans = max(f1, f2)
    return ans

t = int(input())
for _ in range(t):
	print(main())