t=int(input())
for i in range(t):
    a,b,c=map(int,input().split())
    z=0
    while c>=2 and b>=1:
        b=b-1
        c=c-2
        z=z+3
    while a>=1 and b>=2:
        a=a-1
        b=b-2
        z=z+3
    print(z)
        
        
    