#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    while (b > 0 && c > 1) {
      b--;
      c -= 2;
      d += 3;
    }
    while (a > 0 && b > 1) {
      b--;
      c -= 2;
      d += 3;
    }
    cout << d << endl;
    d = 0;
  }
}
