if __name__=="__main__":
    t=int(input())

    while t!=0:
        t-=1
        a,b,c=[int(x) for x in input().split()]

        f1=min(c//2,b)
        c1=f1+min((b-f1)//2,a)

        f1=min(b//2,a)
        c2=f1+min(c//2,(b-(2*f1)))

        print(max(c1,c2)*3)
