n=int(input())
for x in range(n):
    a,b,c=list(map(int,input().split()))
    answer=0
    while True:
        if c>=2 and b>=1:
            c-=2
            b-=1
            answer+=3
        else:
            if b>=2 and a>=1:
                a-=1
                b-=2
                answer+=3
            else:
                break
    print(answer)