def stones(n):
    a, b, c = n[0], n[1], n[2]
    st = 0

    if c//2 <= b:
        st += (((c//2)*2) + (c//2))
        b -= (c//2)
        c -= ((c//2)*2)
    else:
        st += ((b*2) + b)
        b = 0
    if b//2 <= a:
        st += (((b//2)*2) + (b//2))
        a -= (b//2)
        b -= ((b//2)*2)
    else:
        st += ((a*2) + a)
        a = 0
    return st

tc = int(input())
for i in range(tc):
    n = list(map(int, input().split()))
    print(stones(n))