answer = []
for _ in range(int(input())):
    a, b, c = map(int, input().split())

    stones = 0
    cc = c // 2
    if b > cc:
        stones += cc * 3
        b -= cc
    else:
        stones += b * 3
        b = 0
    
    bb = b // 2
    if a > bb:
        stones += bb * 3
    else:
        stones += a * 3

    answer.append(stones)

for ans in answer:
    print(ans)
    