n = int(input())
for i in range(n):
    sum = 0
    a, b, c = map(int, input().split())
    a1, b1, c1 = a, b, c

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