t = int(input())

while t:
    heaps = [int(i) for i in input().split(' ')]
    take_2c = int(heaps[2] // 2)
    take_2c = heaps[1] if take_2c > heaps[1] else take_2c
    take_1b = take_2c
    heaps[1] -= take_1b
    take_2b = int(heaps[1] // 2)
    take_2b = heaps[0] if take_2b > heaps[0] else take_2b
    take_1a = take_2b
    print(take_1a + take_1b + take_2b * 2 + take_2c * 2)
    t -= 1

