import java.util.*;
public class cpeb {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		
		for(int i=0;i<num; i++){
			int x = 0;
			int y = 0;
			int z = 0;
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
		
		
		for(int j=c; j>=2; j-=2){
			if(b<=1) break;
				x++;
		}
		y = b-x;
		for(int f=y; f>=2; f-=2){
			if(a<=z) break;
				z++;
		}
		if(b<=0){
			System.out.println(0);
		}else{
			System.out.println(x*3+z*3);
		}
		}
		
		
	}

}

 	 	 	 	 	 		  		  	 	 		  	  	