n = int(input())

for i in range(n):
    r = 0
    (a, b, c) = map(int, input().split(' '))
    #(a, b, c) = (3,4,5)
    while b >= 1 and c >= 2:
        r += 3
        b -= 1
        c -= 2
    while a >= 1 and b >= 2:
        r += 3
        a -= 1
        b -= 2
    print(r)
