import java.io.*;
import java.io.FileReader;
import java.util.*;
import java.util.zip.InflaterInputStream;

public class Solver {


    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        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 a1 = a;
            int b1 = b;
            int c1 = c;
            int taken = Math.min(a,b/2);
            b -= taken * 2;
            int ans = taken * 3;
            int taken2 = Math.min(b,c/2);
            ans+=taken2*3;
            int taken1 = Math.min(b1,c1/2);
            b1 -= taken;
            int ans1 = taken * 3;
            int taken12 = Math.min(a1,b1/2);
            ans1+=taken12*3;
            out.println(Math.max(ans,ans1));
        }
        out.close();
    }
    static class FastScanner{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() throws IOException {
            while (!st.hasMoreElements())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}
