def solve(a,b,c):
    a1,b1,c1=a,b,c
    count=0
    t=min(b,c//2)
    count+=3*t
    b-=t  
    c-=2*t  
    t=min(a,b//2)
    count+=3*t
    a,b,c=a1,b1,c1 
    count1=0
    t=min(a,b//2)
    count1+=3*t 
    a-=t  
    b-=2*t
    t=min(b,c//2)
    count1+=3*t 
    return max(count,count1)

for _ in range(int(input())):
    a,b,c=map(int,input().split())
    print(solve(a,b,c))
    
    
    
    