t = int(input())
while(t>0):
    stones = 0
    heaps = [int(i) for i in input().split()]
    while(heaps[2]>1 and heaps[1]>0):
        stones += 3
        heaps[2] -= 2
        heaps[1] -= 1
    while(heaps[1]>1 and heaps[0]>0):
        stones += 3
        heaps[1] -= 2
        heaps[0] -= 1
    print(stones)
    t -= 1
