import java.io.*;
import java.util.*;
 
  
   
  public    class Solution{
         public static void main (String args[])throws IOException{
             
             BufferedReader ob = new BufferedReader(new InputStreamReader(System.in));
              
              
              int  t= Integer.parseInt(ob.readLine());
              while(t --> 0){
                  StringTokenizer st = new StringTokenizer(ob.readLine());
                  
                  int a = Integer.parseInt(st.nextToken());
                  int b = Integer.parseInt(st.nextToken());
                  int c = Integer.parseInt(st.nextToken());
                  
                  int count = 0;
                  while(a > 0 || b > 0){
                      if(a >= 1 && b > 2){
                          count+= 3;
                          a--;
                          b -= 2;
                      }else if(b >= 1 && c >= 2){
                          count +=3;
                          b--;
                          c -= 2;
                      }else{
                          break;
                      }
                  }
                  System.out.println(count);
              }
         }
     }
               