
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.StringJoiner;
import java.util.StringTokenizer;


/**
 *
 * @author Kayali
 */
public class Postman {
   
    public static void main(String[] args) throws IOException {
     FastReader in = new FastReader();
       PrintWriter pw = new PrintWriter(System.out);
           int q=in.nextInt();
         while(q-->0){
         int a= in.nextInt();
         int b = in.nextInt();
         int c = in.nextInt();
         int ans = 0;
         if(a>=b)
         { 
             while(a>=1)
             {
                 if(a>=1 && b>=2){
                 ans+=3;a-=1;b-=2;}else {
                 if(b>=1 && c>=2){
                     b-=1;c-=2;
                 ans+=3;
                 }else{break;}
                 }
             }
         }else{
          while(b>=1)
             {
                 if(b>=1 && c>=2){
                     b-=1;
                     c-=2;
                 ans+=3;}else {
                 if(a>=1 && b>=2){
                 ans+=3;
                 a-=1;
                 b-=2;
                 }else{break;}
                 }
             }
         }
             pw.println(ans);
         }
        
        pw.flush();
     pw.close();
    
    }
       
       
    

    
    static class FastReader {
 
        StringTokenizer st;
        BufferedReader br;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public String next() throws IOException {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }
 
        public boolean hasNext() throws IOException {
            if (st != null && st.hasMoreTokens()) {
                return true;
            }
            String s = br.readLine();
            if (s == null || s.isEmpty()) {
                return false;
            }
            st = new StringTokenizer(s);
            return true;
        }
 
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
 
        public String nextLine() throws IOException {
            return br.readLine();
        }
    }
    
}