def stones(n):
    a, b, c = n[0], n[1], n[2]
    st = 0
    if 0 in n:
        return 0
    else:
        if c//2 <= b:
            st += (((c//2)*2) + (c//2))
            b -= (c//2)
            c -= ((c//2)*2)
        if b//2 <= a:
            st += (((b//2)*2) + (b//2))
            a -= (b//2)
            b -= ((b//2)*2)
    return st

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