try:
    n=int(input())
    for i in range(n):
        a,b,c=map(int,input().split())
        if b==0:
            print(0)
        else:
            ans=min(c//2,b)
            b-=ans
            ans+=2*ans
            x=min(b//2,a)
            x+=2*x
            ans+=x
            print(ans)
except:
    pass
