for q in range(int(input())):
    a,b,c = [int(i) for i in input().split()]
    x = a
    y = c // 2
    while 2 * x + y > b and x > 0:
        x -= 1
    while 2 * x + y > b and y > 0:
        y -= 1
    print(3*(x+y))