
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;
            while (b!=0){
                if (c<2){
                    break;
                }
                count+=1;
                count+=2;
                c-=2;
                b-=1;
            }
           // System.out.println(a+" "+b+" "+c+" "+count);
            b-=(b%2);
            int val=b/2;
            if (b==0||count==0){
                System.out.println(count);
                continue;
            }
            System.out.println(count+b+val);
        }
    }
}
