for _ in range(int(input())):
    a, b, c = map(int, input().split())
    ans = 0
    while (b > 0 and c > 1):
        if c > 1 and b > 0:
            ans += 3
            c -= 2
            b -= 1
    while (a > 0 and b > 1):
            if b > 1 and a > 0:
                ans += 3
                b -= 2
                a -= 1
    print(ans)
