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

public class Stones {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //StringTokenizer st = new StringTokenizer(br.readLine());
        //PrintWriter pw = new PrintWriter("Stones.out");

        int t = sc.nextInt();
        for(int i = 0; i<t; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            System.out.println(ans(a,b,c));
        }
    }

    public static int ans(int i, int j, int k){
        if(i < 1 && j < 1 && k < 1){
            return 0;
        }
        if(k < 2 && i > 0 && j > 1){
            return 3 + ans(i-1, j-2, k);
        }
        if(i < 1 && j > 0 && k > 1){
            return 3 + ans(i, j-1, k-2);
        }
        if(j < 1){
            return 0;
        }
        else{
            return Math.max(3 + ans(i-1, j-2, k), 3 + ans(i, j-1, k-2));
        }
    }
}