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

public class Main {
    public static void main(String[] args) {
        MyScanner scanner = new MyScanner();

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

            while((b > 0 && c > 1) || (a > 0 && b > 1)) {
                if(c>b) {
                    c -= 2;
                    b -= 1;
                    sum +=3;
                }else {
                    b -= 2;
                    a -= 1;
                    sum += 3;
                }
            }
            System.out.println(sum);

        }

    }

    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public 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();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    // --------------------------------------------------------
}
