for i in range(int(input())):
               
   a,b,c=map(int,input().split())
   y=1
   count=0
   while(y!=0):

       if(b>=1) and (c>=2):

           c-=2
           b-=1
           count+=1
       elif(a>=1) and (b>=2):

           a-=1
           b-=2
           count+=1

       else:
            y=0


   print(count*3)


   


    
