t=int(input())
for i in range(t):
    a,b,c=map(int,input().split())
    n=c//2
    if b<=n:
        print(b+b*2)
    else:
        c=b-n
        y=c//2
        if a<=y:
            print(a+a*2+n+n*2)
        else:
            print(n+n*2+y+y*2)
        
    