#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int arr[t];
  for (int i = 0; i < t; i++) {
    int a, b, c;
    int sum = 0;
    cin >> a >> b >> c;
    if (b > c) {
      while (a >= 1 && b >= 2) {
        sum += 3;
        a = a - 1;
        b = b - 2;
      }
      while (b >= 1 && c >= 2) {
        sum += 3;
        b = b - 1;
        c = c - 2;
      }
    } else {
      while (b >= 1 && c >= 2) {
        sum += 3;
        b = b - 1;
        c = c - 2;
      }
      while (a >= 1 && b >= 2) {
        sum += 3;
        a = a - 1;
        b = b - 2;
      }
    }
    arr[i] = sum;
  }
  for (int y = 0; y < t; y++) {
    cout << arr[y] << endl;
  }
}
