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