def func(a,b,c):
    sum=0
    val_c=c//2
    if (b>=val_c):
        b=b-val_c
        sum+=(3*val_c)
    else:
        sum+=(3*b)
        c=c-2*b
        b=0
    val_b=b//2
    if (a>=val_b):
        a=a-val_b
        sum+=(3*val_b)
    else:
        sum+=(3*a)
        b=b-2*a
        a=0
    return sum

t=int(input())
ans=[]
for i in range(t):
    a,b,c=(int(i) for i in input().split())
    ans.append(func(a,b,c))
for i in ans:
    print(i)