t=int(input())
while t>0:
    a,b,c=map(int,input().split())
    count=0
    if a==0 or b==0 or c==0:
        pass
    else:
        if c>=2:
            if c//2 > b:
                count += 3*b
                b=0
            else:
                count += 3*(c//2)
                b -= c//2
        if b>=2:
            if b//2 > a:
                count += 3*a
                a=0
            else:
                count += 3*(b//2)
                a -= b//2
    print(count)
    t -= 1
    
                
        
    
