#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b, c, max, k;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> a >> b >> c;
    k = 0;
    max = (a) > (c) ? (a) : (c);
    if (b == 0) {
      cout << 0;
    } else {
      while (1 == 1) {
        if (b > 0 and c >= a and c > 1) {
          b -= 1;
          c -= 2;
          k += 3;
        } else if (b > 1 and a > c) {
          a -= 1;
          b -= 2;
          k += 3;
        } else if (b == 1 and c > 1) {
          b -= 1;
          c -= 2;
          k += 3;
        } else {
          break;
        }
      }
      cout << k << endl;
    }
  }
  return 0;
}
