import java.util.Scanner;

public class Stones{
	public static Scanner sc = new Scanner(System.in);
	public static int T;
	public static int a,b,c;
	public static int stones;
	
	public static void main(String args[]){
		T = sc.nextInt();
		
		while(T-- > 0){
			stones = 0;
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();

			if(b > 0 && c > 0 && b > c/2){
				stones += c - (c%2);
				b -= c/2;
				stones += c/2;
				c = c%2;
			}
			if(a > 0 && b > 0 && a > b/2){
				stones += b - (b%2);
				a -= b/2;
				stones += b/2;
				b = b%2;
			}
			
			System.out.println(stones);
		}
	}
}
