
import java.util.Scanner;

public class Stones {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
            int a,b,c;
            a=sc.nextInt();
            b=sc.nextInt();
            c=sc.nextInt();
            int count=0;
            for (int i=1;i<=Math.min(b,c);i++){
                count+=3;
                c-=2;
                b-=1;
                if (c<2||b<1){
                    break;
                }
            }
            for (int i=1;i<=Math.min(a,b);i++){
                count+=3;
                b-=2;
                a-=1;
                if (b<2||a<1){
                    break;
                }
            }
            System.out.println(count);
        }
    }
}
