import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastReader read = new FastReader();
        StringBuilder out = new StringBuilder();
        int t = read.nextInt();
        while (t-- > 0) {
            int a = read.nextInt();
            int b = read.nextInt();
            int c = read.nextInt();
            int a2 = a;
            int b2 = b;
            int c2 = c;
            int ans1 = 0;
            int ans2 = 0;
            while (true) {
                if (a >= 1 && b >= 2) {
                    a -= 1;
                    b -= 2;
                    ans1 += 3;
                } else if (b >= 1 && c >= 2) {
                    b -= 1;
                    c -= 2;
                    ans1 += 3;
                } else {
                    break;
                }
            }
            a = a2;
            b = b2;
            c = c2;
            while (true) {
                if (b >= 1 && c >= 2) {
                    a -= 1;
                    c -= 2;
                    ans2 += 3;
                } else if (a >= 1 && b >= 2) {
                    a -= 1;
                    b -= 2;
                    ans2 += 3;
                } else {
                    break;
                }
            }
            out.append(Math.max(ans1 , ans2)).append('\n');
        }
        System.out.print(out);
    }

}

class FastReader {

    BufferedReader br;
    StringTokenizer st;

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