import java.util.*;
import java.io.*;
public class temp{
    static boolean check(int a[]){
        //check w
        HashSet<Integer>H=new HashSet<>();
        for(int i=1;i<a.length;++i){
              if(a[i-1]!=a[i]){
                 //check whether the elemetne is present of rnot
                 if(H.contains(a[i])){
                     return false;
                 }
                 
              }
              H.add(a[i]);

        }
        return true;
    }
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int t=scan.nextInt();
        while(t-->0){
             int a=scan.nextInt();
             int b=scan.nextInt();
             int c=scan.nextInt();
             int count=0;
           
           while(b>=2&&c>=2){
                 count+=3;
                 --b;
                 c=c-2;


           }
           
          while(a>=1&&b>=2){
              count+=3;
              --a;
              b=b-2;
          }
          System.out.println(count);
            }        
        }
    }
