t = int(input())

for w in range(t):
    a, b, c = [int(i) for i in input().split()]
    ans = 0

    if b == 0:
        print(0)
        continue

    if c == 0:
        print((b // 2) * 2 + (b // 2))
        continue

    if a == 0:
        print((c // 2) * 2 + (c // 2))
        continue

    q = c // 2
    c -= (q * 2)
    b -= q
    ans += (q * 2 + q)

    if b >= 2:
        g = b // 2
        b -= (g * 2)
        a -= g
        ans += (g * 2 + g)

    print(ans)