 
TestCase = input()

if( TestCase.isdigit() ):
    TestCase = int(TestCase)
 
while( TestCase > 0 ):
    listi = list( map( int,input().split() ) )
    count = 0
    
    while( listi[2] > 1 and listi[1] > 0  ):
        count += (1+2)
        listi[2] -= 2
        listi[1] -= 1
        
    while( listi[1] > 1 and listi[0] > 0   ):    
        count += (1+2)
        listi[1] -= 2
        listi[0] -= 1
    
    print(count)
        
    TestCase -= 1