import sys,math,fractions,bisect
def fi():
    return int(sys.stdin.readline())

def fi2():
    return map(int, sys.stdin.readline().split())

def fi3():
    return sys.stdin.readline()

def fo(*args):
    for s in args:
        sys.stdout.write(str(s)+' ')
    sys.stdout.write('\n')
INF=10**9+7
sys.setrecursionlimit(INF)

#main
t=fi()
for T in range(t):
    a,b,c = fi2()
    res=0
    o=0
    o=min(b,c/2)
    res+=o+o*2
    b-=o
    o=min(a,b/2)
    res+=o+o*2
    fo(res)
    
    
           

                           
                

            
        

        
        
        
    
    
    
            




    
            


    

        
    
    
        
        
        
    
    
    
            
            
            
            
    
                
    
        
    

        
        
    


    
    
            
                
            
            
        
    
    
        
    
    
    
            

    
    



    
        
            
    
        
