for _ in range(int(input())):
    (p,q,r)=map(int,input().split())
    c=0
    while(1):
        if(r>=2 and q>=1):
            r=r-2
            q=q-1
            c=c+3
        else:
            break
    while(1):
        if(q>=2 and p>=1):
            q=q-2
            p=p-1
            c=c+3
        else:
            break
    print(c)

