t=int(input())
while t>0:
    t=t-1
    a,b,c=map(int,input().split())
    k=0
    if a+b>b+c:
        while a>=1 and b>=2:
            k=k+3
            a=a-1
            b=b-2
        while b>=1 and c>=2:
            k=k+3
            b=b-1
            c=c-2
        print(k)    
    else:
        while b>=1 and c>=2:
            k=k+3
            b=b-1
            c=c-2
        while a>=1 and b>=2:
            k=k+3
            a=a-1
            b=b-2
        print(k) 
        