t=int(input())
ans=[]
for i in range(t):
    a,b,c=map(int,input().split())
    k=0
    while c>=2 and b>=1:
        k+=3
        c-=2
        b-=1
    while b>=2 and a>=1:
        k+=3
        b-=2
        a-=1
    ans.append(k)
[print(i) for i in ans]