t = int( input() )
for _ in range(t):
    a, b, c = map( int, input().split() )
    m = 0
    for i in range( a + 1 ):
        for j in range( b + 1 ):
            if 2 * i + j <= b and 2 * j <= c:
                m = max( m, 3 * ( i + j ) )
    print( m )
