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