import java.io.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Solution {

    private static PrintWriter out;

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next(){
            while(st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            return st.nextToken();
        }

        String nextLine() {
            String result = "";

            try {
                result = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return result;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        float nextFloat(){
            return Float.parseFloat(next());
        }

        long nextLong(){
            return Long.parseLong(next());
        }
    }

    public static void main(String args[]) {
        MyScanner scan = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = scan.nextInt();

        for(int i = 0; i < n; i++){
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();

            int result = 0;
            if(c > b) {
                int d = c/2;

                if(d < b) {
                    result += (d*2 + d);
                    b -= d;

                    int e = b / 2;

                    if(e < a) {
                        result += (e*2 + e);
                        a -= e;
                    } else {
                        result += (a*2 + a);
                    }
                } else {
                    result += (b*2 + b);
                }
            } else {
                int d = b/2;

                if(d < a) {
                    result += (d*2 + d);

                    if(b % 2 != 0) {
                        if(c >= 2) {
                            result += 3;
                        }
                    }
                } else {
                    result += (a*2 + a);
                    b -= (a*2);

                    if(c >= 2) {
                        int e = c / 2;

                        if(b > e) {
                            result += (e*2 + e);
                        } else {
                            result += (b*2 + b);
                        }
                    }
                }
            }

            out.println(result);
        }

        out.close();
    }
}