
def solve (a, b, c):
    stones = 0
    while c>1 and b > 0:
        # 2nd op
        b -= 1
        c -= 2
        stones += 3
        
    while b>1 and a>0:
        # 1st op
        a -= 1
        b -= 2
        stones += 3
        
    print (stones)
    return

def main ():
    t = int (input ())

    while t:
        t -= 1
        a, b, c = ( int (i) for i in input ().split () )
        
        solve (a, b, c)

    return


if __name__ == '__main__':
    main ()