for _ in range(int(input())):
    a,b,c=list(map(int,input().split()))
    q=a
    w=b
    e=c
    c1=c//2
    if b>=c1 and c1>=1:
        c-=c1*2
        b-=c1
    elif b<c1 and c1>=1:
        c-=b*2
        b=0
    b1=b//2
    if a>=b1 and b1>=1:
        b-=b1*2
        a-=b1
    elif a<b1 and b1>=1:
        b-=a*2
        a=0
    print(q-a+w-b+e-c)
