#include <bits/stdc++.h>
using namespace std;
int ans(int a, int b, int c, int d) {
  if ((a >= 2 || b >= 2 || c >= 2) && b != 0 && (a > 0 || c > 0)) {
    if (b > c) {
      if (b >= 2) {
        a--;
        b = b - 2;
        d = d + 3;
      } else
        b = 0;
    } else {
      if (c >= 2) {
        b--;
        c = c - 2;
        d = d + 3;
      } else
        b = 0;
    }
    return d + ans(a, b, c, d);
  } else
    cout << d << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, k;
    cin >> a >> b >> c;
    ans(a, b, c, 0);
  }
}
