for i in range(int(input())):
    a,b,c=map(int,input().split())
    ans=0
    while(b>0 and c>1):
        ans+=3
        b-=1
        c-=2
    if (b==0):
        print(ans)
    else:
        while(a>0 and b>1):
            ans+=3
            a-=1
            b-=2
        print(ans)