
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author ASUS-PC
 */
public class A {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int nInput = Integer.parseInt(br.readLine());
        
        for (int i = 0; i < nInput; i++) {
            int result = 0;
            String[] data = br.readLine().split(" ");
            int one = Integer.parseInt(data[0]);
            int two = Integer.parseInt(data[1]);
            int three = Integer.parseInt(data[2]);
            while (two > 2 && three > 1) {
                two --;
                three -= 2;
                result++;
            }
            while (one > 0 && two > 1) {
                one--;
                two -= 2;
                result++;
            }
            
            System.out.println(result * 3);
        }

    }
}
