# cook your dish here
# cook your dish here
t=int(input())
for _ in range(t):
    count=0
    a,b,c=map(int,input().split(" "))
    if b>c//2:
        count+=(c//2)*3
        b=b-c//2
        if b!=0:
            if a>b//2:
                count+=(b//2)*3
            else:
                count+=a*3
                
    else:
        count+=b*3
            
        
    print(count)