n = int(input())

while (n > 0):
    numbers = input().split(" ")
    a = int(numbers[0])
    b = int(numbers[1])
    c = int(numbers[2])

    cnt = 0
    while (b-1 >= 0 and c-2 >= 0):
        cnt += 3
        b -= 1
        c -= 2
    while (a-1 >= 0 and b-2 >= 0):
        cnt += 3
        a -= 1
        b -= 2
    print(cnt)
    
    n -= 1

