t = int(input())
while t>0:
    t = t-1
    a,b,c = map(int,input().split())
    stones1 = 0
    stones2 = 0
    while c>=2 and b>=1:
        c = c-2
        b = b-1
        stones1 += 3
    while b>=2 and a>=1:
        b -= 2
        a -= 1
        stones1 += 3

    while b>=2 and a>=1:
        b -= 2
        a -= 1
        stones2 += 3
    while c>=2 and b>=1:
        c = c-2
        b = b-1
        stones2 += 3
    print(max(stones1,stones2))