t=int(input())
for i in range(t):
    a,b,c = map(int, input().strip().split(' '))
    s=0
    
    if b>=c//2:
        d=3*(c//2)
        s+=d
        b-=d//3
    
    else:
        s+=b*3
        b=0
    
        
    if a>=b//2:
        e=3*(b//2)
        s+=e
        
    print(s)
        
    
    