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