t=int(input())
while t>0:
    t-=1
    a,b,c=map(int,input().split())
    if b==0:
        print(0)
        continue
    x=c//2
    sumi=0
    if b>=c//2:
        sumi+=3*(c//2)
        b-=c//2
        #print(sumi)
        sumi+=min(a,b//2)*3
        print(sumi)
        continue
    else:
        sumi=3*b
        print(sumi)
        