for _ in range(int(input())):
    a,b,c = map(int,input().split())
    d=b//1
    e=c//2
    ans=0
    
    if(d >=1 and e>=1):
        p=min(d,e)
        
        b=b-p
        ans+=3*p
    d=a//1
    e=b//2
    
    if(d>=1 and e>=1):
        p=min(d,e)
        
        ans+=3*p
        
    print(ans)

    
    