for i in range(int(input())):
    count=0
    a,b,c=map(int,input().split())
    c=c//2
    if(c>0 and b>0):
        count=count+(min(c,b))*3
        b=b-min(c,b)
    if(b>1 and a>0):
        b=b//2
        count=count+(min(a,b))*3
    print(count)
        
        
        
