n = int(input())
for i in range(n):
    list_of_piles = list(map(int, input().split()))
    pile1 = list_of_piles[0]
    pile2 = list_of_piles[1]
    pile3 = list_of_piles[2]
    counter = 0
    while pile2 > 0 and pile3 > 1:
        counter += 3
        pile2 -= 1
        pile3 -= 2
    while pile1 > 0 and pile2 > 1:
        counter += 3
        pile1 -= 1
        pile2 -= 2
    print(counter)