t = int(input())
for _ in range(t):
    a, b, c = map(int, input().split())
    if b == 0:
        print(0)
    else:
        output = min(b//1, c//2)
        b -= output
        c -= output * 2
        output += min(a//1, b//2)
        output *= 3
        print(output)
