def ab():
    
    a,b,c=list(map(int,input().split()))
    sum=a+b+c
    while True:
        if(c>=2 and b>=1):
            c=c-2
            b=b-1
        else:
            break
    while True:
        if(a>=1 and b>=2):

            a=a-1
            b=b-2
        else:
            break
    sumf=a+b+c
    print(sum-sumf)    

    
    

n=input()
for i in range(0,int(n)):
    ab() 