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