n = int(input())
for i in range(n):
    a, b, c = map(int, input().split())
    best = 0
    for i in range(min(a, b // 2) + 1):
        now_ans = i * 3 + min(b - 2 * i, c // 2) * 3
        if now_ans > best:
            best = now_ans
    print(best)

