T, *ABC = map(int, open(0).read().split())

for a, b, c in zip(*[iter(ABC)] * 3):
    ans = 0
    for x in range(a + 1):
        for y in range(c // 2 + 1):
            if 2 * x + y <= b:
                ans = max(ans, 3 * (x + y))
    print(ans)
