t = int(input())

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