t=int(input());i=0
while i<t:
    s=0
    a,b,c=map(int,input().split())
    while b>0:
        if c<=1:
            break
        s+=3;b-=1;c-=2
    while a>0:
        if b<=1:
            break
        s+=3;a-=1;b-=2
    print(s)
    i+=1