t = int(input())
for p in range(t):
    a, b, c = [int(s) for s in input().split()]
    if c%2:
        c -= 1
    if 2*a + c//2 <= b:
        ans = 3*(a + c//2)
        print(ans)
        continue
    if c//2 <= b:
        y = c//2
        x = min(a, (b-y)//2)
        ans = 3*(x+y)
        print(ans)
        continue
    else:
        ans = 3*b
        print(ans)