if __name__=="__main__":
    t=int(input())
    for kcase in range(t):
        a,b,c=map(int,input().split())
        #ans=3*((b-c//2)//2)+3*(c//2)
        ans=0
        if b<=(c//2):
            ans=ans+3*(b)
            b=0
        else:
            ans=ans+3*(c//2)
            b=b-(c//2)
        if (b//2)>=a:
            ans=ans+3*a
        else:
            ans=ans+3*(b//2)
        print(ans)