/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		int t=s.nextInt();
		while(t-->0)
		{int a=s.nextInt();
		int b=s.nextInt();
		int c=s.nextInt();
		int count=0;
		while(b>0)
		{if(a>=1 && b>=2)
		{count+=3;a=a-1;
		b=b-2;}
		if(b>=1 && c>=2)
		{count+=3;
		b=b-1;c=c-2;}
		if(a==0 || c<=1 || b==0)
		break;}
		System.out.println(count);}
	}
}