count = int(input())
sets = []
while(count > 0):
    sets.append(list(map(int, input().split())))
    count -= 1
stones = 0
for _set in sets:
    if(_set[1] == 0):
        print(0)
        continue
    while(_set[2] > 1 and _set[1] > 0):
        stones += 3
        _set[2] -= 2
        _set[1] -= 1
    while(_set[1] > 1 and _set[0] > 0):
        stones += 3
        _set[1] -= 2
        _set[0] -= 1
    print(stones)
    stones = 0