n=int(input())
for i in range(n):
    a,b,c=[int(i) for i in input().split()]
    sum=0
    e=b//1
    f=c//2
    b=b-(min(e,f))
    c=c-(min(e,f))
    sum=sum+(3*min(e,f))
    sum=sum+(3*min(a//1,b//2))
    print(sum)