l=[]
for i in range(int(input())):
    a,b,c=map(int,input().split())
    s=0
    while(1):
        if b>=1 and c>=2:
            s+=3
            b=b-1
            c=c-2
        else:
            break
    while(1):
        if a>=1 and b>=2:
            s+=3
            a=a-1
            b=b-2
        else:
            break
    l.append(s)
print(*l,sep="\n")