t = int(input())

count = 0
ans = []

while count < t:
    sto = input()
    a,b,c = sto.split()
    if int(b) == 0 :
        ans.append(0)
    else:
        times = int(c)//2
        if int(b) < times :
            tot = int(b) + int(b)*2
            ans.append(tot)
        else:
            tot = times + times*2
            b = int(b) - times
            if b < 2 :
                ans.append(tot)
            else:
                times2 = int(b)//2
                tot += times2 + times2*2
                ans.append(tot)
    count += 1

for y in ans:
    print (y)
                
        

    
 





        




    




    

    
    

        
        
        
    
    

    
        



        
        
        
           
        
        
    
    




    
            
        





            
        
            

        
            



        
        
    
        



            


    
    







    



        
        
        
        


            



        
            

    


    

    



        


        



    
        
        

    







    
    
 

    

        
    
            
    




    


        



    





        
            
        
    
