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