# cf 1236 A 800
t = int(input())
for _ in range(t):
    a, b, c = map(int, input().split())
    x = 0
    while (b >= 2 and a >= 1) or (c >= 2 and b >= 1):
        if min(c // 2, b) > min(b // 2, a):
            c -= 2
            b -= 1
        else:
            b -= 2
            a -= 1
        x += 3
    print(x)
