def func(a, b, c):
    count = 0
    while c >= 2 and b >= 1:
    	c -= 2
    	b -= 1
    	count += 3
    while a >= 1 and b >= 2:
    	a -= 1
    	b -= 2
    	count += 3
    return count
t = int(input())
stones = []
for i in range(t):
    s = list(input().split(' '))
    stones.append(func(int(s[0]), int(s[1]), int(s[2])))
for i in stones:
    print(i)
