t = int(input())

for i in range(t):
    stones = list(map(int , input().split(' ')))
    
    total = sum(stones)
    third = min(stones[2]//2, stones[1])
    
    stones[2] -= third*2
    stones[1] -= third
    
    second = min(stones[1]//2 ,stones[0])
        
    stones[1] -= second*2
    stones[0] -= second
    
    total -= sum(stones)
    
    print(total)