import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int lim = in.nextInt();
    in.nextLine();
    for(int i = 0; i < lim; i++){
      new Solution(in.nextInt(), in.nextInt(), in.nextInt());
      in.nextLine();
    }
  }
}
class Solution{
  private int one;
  private int two;
  private int three;
  private int stones = 0;

  public Solution(int one, int two, int three){
    this.one = one;
    this.two = two;
    this.three = three;
    System.out.println(runSolution());
  }

  public int runSolution(){
    if(this.one < 1 && this.two < 1){
      return 0;
    }
    else if(this.two < 2 && this.three < 2){
      return 0;
    }
    else{
      boolean running = true;
      while(running){
        if(this.one >= 1 && this.two >= 2){
          stones += 3;
          this.one -= 1;
          this.two -= 2;
        }
        if(this.two >= 1 && this.three >= 2){
          stones += 3;
          this.two -= 1;
          this.three -= 2;
        }
        if(!((this.one >= 1 && this.two >= 2) || (this.two >= 1 && this.three >= 2))){
          running = false;
        }
      }
    return stones;
    }
  }
}