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

public final class Solution
{
    public static void main (String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        for(int p=0;p<t;p++)
        {
            int a,b,c,x;
            a=sc.nextInt();
            b=sc.nextInt();
            c=sc.nextInt();
            x=0;
            while(a>=1 && b>=2)
            {
                //count of a 1
                //count of b 2
                x=x+3;
                a=a-1;
                b=b-2;
                while(b>=1 && c>=2)
                {
                    //count of b 1
                    //count of c 2
                    x=x+3;
                    b=b-1;
                    c=c-2;
                }
            }
            System.out.println(x);
        }
    }
}