for i in range(int(input())):
    a,b,c=map(int,input().split())
    sum=0
    if b==0:
        print(0)
    else:
        sum+=3*(min(b,c//2))
        if min(b,c//2)!=b:
            sum+=3*(min((b-c//2)//2,a))
        print(sum)
