t=int(input())
def solve(a,b,c):
    max_stones=0
    while(c>1 and b>0):
        c-=2
        b-=1
        max_stones+=3
    while(b>1 and a>0):
        b-=2
        a-=1
        max_stones+=3
    return(max_stones)
for i in range(t):
    stones=list(int(i) for i in input().split())
    a=stones[0]
    b=stones[1]
    c=stones[2]
    print(solve(a,b,c))
    
