n = int(input())
mas = []
for i in range(0, n, 1):
    mas.append(list(map(int, input().split(' '))))
#print(mas)
for i in range(0, n, 1):
    counter = 0
    while mas[i][2] >= 2 and mas[i][1] >= 1:
        mas[i][2] -= 2
        mas[i][1] -= 1
        counter +=3
    while mas[i][1] >= 2 and mas[i][0] >= 1:
        mas[i][1] -= 2
        mas[i][0] -= 1
        counter += 3
    print(counter)

