a = int(input())

for _ in range(a):
    b = list(map(int, input().split()))
    res = 0

    if b.count(0) >= 1:
        print(0)
    else:
        while b[1] > 0 and b[2] >= 2:
            b[1] -= 1
            b[2] -= 2
            res += 3
        while b[0] > 0 and b[1] >= 2:
            b[0] -= 1
            b[1] -= 2
            res += 3
        print(res)
