import java.util.*;
public final class Stones{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int testcases = sc.nextInt();
        for(int i=0; i<testcases; i++){
            int[] heap = new int[3];
            heap[0] = sc.nextInt();
            heap[1] = sc.nextInt();
            heap[2] = sc.nextInt();
            int count = 0;
            if(heap[1]==0){
                System.out.println(0); 
                continue;               
            }
            if(heap[2]>heap[1]){
                while(heap[2]>=2 && heap[1]>=1){
                    heap[2] -=2;
                    heap[1] -=1;
                    count +=3;
                }
                while(heap[0]>=1 && heap[1]>=2){
                    heap[1] -=2;
                    heap[0] -=1;
                    count +=3;    
                }
            }else{
                while(heap[0]>=1 && heap[1]>=2){
                    heap[1] -=2;
                    heap[0] -=1;
                    count +=3;    
                }
                while(heap[2]>=2 && heap[1]>=1){
                    heap[2] -=2;
                    heap[1] -=1;
                    count +=3;
                }
            }
            System.out.println(count);
        }
        sc.close();
    }
}