for _ in  range(int(input())):
    a,b,c = map(int,input().split())
    count,f=0,0
    if b == 0:
        print(0)
        
    else:
        while c>=1 and b>0:
            count+=3
            c-=2
            b-=1
        if b>=2:
            while a>=1 and b!=0:
                count+=3
                a-=1
                b-=2
        print(count)