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