

def take_stones(a, b, c):
    res = 0
    if a * b * c == 0:
        return res

    while a * b * c != 0:
        if b < 2 and c < 2:
            break
        if b >= c:
            b -= 2
        elif b < c:
            c -= 2
        res += 3
        a -= 1
    return res

take_stones(3, 3, 3)

t = int(input())
for _ in range(t):
    a, c, b = map(int, input().split())
    print(take_stones(a, b, c))



