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