

import java.util.Scanner;

public class Tester {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] ans = new int[t];
        for(int i = 0; i < t; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if(a == 0 || b == 0 || c == 0){
                ans[i] = 0;
                continue;
            }
            boolean isPass = false;
            while(!isPass){
                if(b >= 1 && c >= 2){
                    b--;
                    c -= 2;
                    ans[i] += 3;
                }
                else if(a >= 1 && b >= 2){
                    a--;
                    b -= 2;
                    ans[i] += 3;
                }
                else
                    isPass = true;
            }
        }
        for(int i = 0; i < ans.length; i++){
                System.out.println(ans[i]);
            }
    }

}
