for i in range(int(input())):
    a,b,c=input().split()
    d=int(c)//2
    b=int(b)
    f=min(b,d)
    ans= f+ 2*f
    b=b-f
    g=b//2
    a=int(a)
    h=min(a,g)
    ans=ans+ h + 2*h
    print(ans)