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