num_cases = int(input())
for case in range(num_cases):
    stones = [int(x) for x in input().split()]
    res = 0
    third = min(stones[1], int(stones[2] / 2))
    res += third * 3
    stones[1] -= third
    stones[2] -= third * 2
    second = min(stones[0], int(stones[1] / 2))
    res += second * 3
    print(res)