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

public class StoneProb {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int tst = sc.nextInt();
		while(tst-->0) {
			int a = sc.nextInt(); 
			int b = sc.nextInt();
			int c = sc.nextInt();
			int count = 0, count1 = 0, a1 =a, b1 =b, c1 =c;
			
			int cval = c/2, ccnt = 0;
			//System.out.println(cval+", taking from c is "+(cval*2)+ ", taking from b is " + b);
			if(cval > b) {
			    count += b*3;
			} else {
			    count += cval*3;
			    b -= cval;
			}
			//.out.println("Remining b value is "+b);
			
			
			int bval = b/2, bcnt = 0;
			if(bval > a) {
			    count += a*3;
			} else {
			    count += bval*3;
			}
			
			
			
			bval = b1/2; bcnt = 0;
			if(bval > a1) {
			    count1 += a1*3;
			    b1 -= a1*2;
			} else {
			    count1 += bval*3;
			    b1 -= bval*2;
			}
			
			cval = c1/2; ccnt = 0;
			//System.out.println(cval+", taking from c is "+(cval*2)+ ", taking from b is " + b);
			if(cval > b1) {
			    count1 += b1*3;
			} else {
			    count1 += cval*3;
			}
			
			if(count > count1)
			System.out.println(count);
			else 
			System.out.println(count1);
		}
	}
}