n=int(input())
for i in range(n):
    a,b,c=[int(i) for i in input().split()]
    d=max(b,c)
    e=d//2
    sum=0
    if(a==0 or b==0 or c==0):
        print(0)
    elif(b>=c):
        b=b-(2*e)
        b=min(b//1,c//2)
        sum=sum+(e+b)*3
        print(sum)
    else:
        c=c-(2*e)
        b=b-(1*e)
        b=min(a//1,b//2)
        sum=sum+(e+b)*3
        print(sum)
        