#include <bits/stdc++.h>
using namespace std;
int fun(int a, int b, int c) {
  if (b < 1)
    return 0;
  else if (a < 2 && c < 2)
    return 0;
  else if (a < 1 && b > 0 && c > 1)
    return 3 + fun(a, b - 1, c - 2);
  else if (a > 0 && b > 1 && c < 2)
    return 3 + fun(a - 1, b - 2, c);
  else
    return 3 + max(fun(a - 1, b - 2, c), fun(a, b - 1, c - 2));
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    int a, b, c;
    cin >> a >> b >> c;
    cout << fun(a, b, c) << endl;
  }
}
