t = int(input())
for _ in range(t):
    a, b, c = [int(x) for x in str(input()).split()]
    stones = 0
    stones  = min(b, c//2)
    b = b - stones
    stones = 3*stones
    stones = stones + 3*min(a, b//2)
    print(stones)
