t = int(input())
i = 0
while i < t:
    mass = list(input().split())
    a = int(mass[0])
    b = int(mass[1])
    c = int(mass[2])
    answer = 0
    while (c > 1) and (b > 0):
        b -= 1
        c -= 2
        answer += 3

    while (b > 1) and (a > 0):
        b -= 2
        a -= 1
        answer += 3
    print (answer)
    i += 1