n = int(input())
for i in range(n):
    L = [int(j) for j in input().split()]
    stones = 0
    while(L[2]>=2 and L[1]>=1):
        L[1]-=1
        L[2]-=2
        stones+=3
    while(L[0]>=1 and L[1]>=2):
        L[0]-=1
        L[1]-=2
        stones+=3
    print(stones)