import java.io.*;
import java.util.*;

public class div_2_593_a {
	public static void main(String args[]){
		FScanner in = new FScanner();
		PrintWriter out = new PrintWriter(System.out);
		int t = in.nextInt();
		while(t-->0) {
        int a=in.nextInt();
        int b=in.nextInt();
        int c=in.nextInt();
        int d=0;
     //   while(a!=0 || b!=0 || c!=0 ){
        while(a>=1 && b>2)
         { 
         a=a-1;b=b-2;
         d+=3;
         }
         while(b>=1 && c>=2)
         {
         	b=b-1;
            c=c-2;
            d+=3;
         }
         //}
         out.println(d);

		 }
		out.close();
	}

    static class FScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer sb = new StringTokenizer("");
 
		String next(){
			while(!sb.hasMoreTokens()){
				try{
					sb = new StringTokenizer(br.readLine());
				} catch(IOException e){ }
			}
			return sb.nextToken();
		}
		String nextLine(){
			try{ return br.readLine(); } 
			catch(IOException e) { } return "";
		}
 
		int nextInt(){
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
 
		float nextFloat(){
		return Float.parseFloat(next());
		}
		
		double nextDouble(){
		return Double.parseDouble(next());
		}
	}
}
	