import java.util.Scanner;

public class Main {
	public static void main(String args[]){
	Scanner in=new Scanner(System.in);
	int a=in.nextInt();	
		while(in.hasNext()){
		int b=in.nextInt();
		int c=in.nextInt();
		int d=in.nextInt();
		int sum=0;
			if(c==0){
				System.out.print(0);
			}
			if(b>0 && c>0 && d>0){
				d=d-(d%2);
				b=(c-d/2)/2;
				c=b*2+d/2;
				sum=b+c+d;
				System.out.println(sum);
			}
			}
		}
	}



   	 				 		     	  		 	     	