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