/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    FastReader fr = new FastReader();
	    int t = fr.nextInt();
	    
	    while(t-->0){
	        int a = fr.nextInt(),b = fr.nextInt(),c = fr.nextInt();
	        int sum=0;
	        if(b>=c){
	        if(a>0&&b>0){
	           int x = b/2;
	           if(a>=x){
	               sum+=(x+2*x);
	               b=b-2*x;
	           }else{
	               sum+=(a+a*2);
	               b=b-a*2;
	           }
	        }
	        if(b>0&&c>0){
	            int x = c/2;
	            if(b>=x){
	                sum+=(x+x*2);
	                c=0;
	            }else{
	                sum+=(b+b*2);
	                c=c-b*2;
	            }
	        }
	    }else{
	        if(b>0&&c>0){
	            int x = c/2;
	            if(b>=x){
	                sum+=(x+x*2);
	                b=b-x;
	            }else{
	                sum+=(b+b*2);
	                b=0;
	            }
	        }
	        if(a>0&&b>0){
	            int x = b/2;
	            if(a>=x){
	                sum+=(x+x*2);
	                b=0;
	            }else{
	                sum+=(a+a*2);
	                a=0;
	            }
	        }
	    }
	    System.out.println(sum);
	        
	        
	    }
	    
	}
}
class FastReader {
 
    BufferedReader bf;
    StringTokenizer st;
 
    public FastReader() {
        bf = new BufferedReader(new InputStreamReader(System.in));
    }
 
    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(bf.readLine());
            } catch (Exception e) {
                System.out.println(e);
            }
        }
        return st.nextToken();
    }
 
    int nextInt() {
        return Integer.parseInt(next());
    }
 
    long nextLong() {
        return Long.parseLong(next());
    }
 
    double nextDouble() {
        return Double.parseDouble(next());
    }
 
    String nextLine() {
        String str = "";
        try {
            str = bf.readLine();
        } catch (Exception e) {
            System.out.println(e);
        }
        return str;
    }
}
