import java.util.Scanner;

public class A2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int count = 0;
            boolean stop = true;
            boolean locka = true;
            boolean lockb = true;
            while(stop){
                if(b<=0) break;
                if(a<=0 && b<=1) {
                    locka = false;
                }
                if(b<=0 && c<=1) {
                    lockb = false;
                }
                if(!lockb && !locka) stop = false;

                if(a>b && locka) {
                    count += 3 ;
                    a--;
                    b-=2;

                }
                else if (b>=a&&lockb){
                    count+=3;
                    b--;
                    c-=2;

                }
            }
            System.out.println(count);
        }
    }
}
