import math


def input_int():
    return list(map(int, input().split()))


def solve():
    [a, b, c] = input_int()
    d = min(c // 2, b)
    e = min(a, (b - d) // 2)
    print((d + e) * 3)
    return


[n] = input_int()
for i in range(0, n):
    solve()
