def solve():
    for _ in range(int(input())):
        a, b, c = map(int, input().split())
        total = 0
        _b = max(0, b-c//2) if c else b
        total += 3*(b-_b)
        _a = max(0, a-_b//2) if _b else a
        total += 3*(a-_a)
        print(total)
solve()
