for _ in range(int(input())):
    a,b,c=map(int,input().split())
    s=0
    if b==0:
        print(0)
    else:
        t=c//2
        if b>t:
            s+=3*t
            r=(b-t)//2
            if a>=r:
                s+=3*r
            else:
                s+=a*3
            print(s)

        else:
            s+=3*b
            print(s)

