n = int(input())
for _ in range(n):
    cont = 0
    stones = input().split(' ')
    a = int(stones[0])
    b = int(stones[1])
    c = int(stones[2])

    aux = min(b, int(c/2))
    cont += aux + aux*2

    b -= aux

    aux = min(a, int(b/2))
    cont += aux + aux*2
    
    print(cont)
