for i in range(int(input())):
    a,b,c=map(int,input().split())
    ans=0
    if(c>=2*b):
        ans+=3*b
    else:
        ans+=c//2+(c//2)*2
        b-=c//2
    if(b>=a*2):
        ans+=3*a
    else:
        ans+=b//2+(b//2)*2
    print(ans)