n=int(input())
while(n):
    ans=0
    a,b,c=list(map(int,input().split()))
    while b>=1 and c>=2:
        
        b=b-1
        c=c-2
        ans+=3
    while a>=1 and b>=2:
        a=a-1
        b=b-2
        ans+=3
    print(ans)    
    n-=1


