case = int(input())

for _ in range(case):
    a, b, c = map(int, input().split())
    
    stone = 0
    
    # 2nd opt
    x = min(b, int(c/2))
    stone += x*3
    
    # 1st opt
    b -= x
    x  = min(a, int(b/2))
    stone += x*3
    
    print(stone)