import java.util.Scanner;

public class _1236A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int cnt = 0;
            if (a>=1 && b>=2) cnt += Math.min(a,b);
            while (b>=2 && c>=2) {
                c -= 2;
                b -= 1;
                cnt += 3;
            }
            System.out.println(cnt);
        }
    }
}
