import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int t = sc.nextInt();
        
        while(t-- > 0) {
            
            int h1 = sc.nextInt();
            int h2 = sc.nextInt();
            int h3 = sc.nextInt();
            
            int total = 0;
            
            while( (h1>=1 && h2>=2) || (h2>=1 && h3>=2) ) {
                
                if(h1>=1 && h2>=2) {
                    total += 3;
                    h1--;
                    h2 -= 2;
                }
                if(h2>=1 && h3>=2) {
                    total += 3;
                    h2--;
                    h3 -= 2;
                }
            }
            System.out.println(total);
        }
    }
}
