#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, sum = 0;
    cin >> a >> b >> c;
    if (b > 0) {
      int mina = a < b / 2 ? a : b / 2;
      int minb = b < c / 2 ? b : c / 2;
      if (mina > minb) {
        sum += 3 * mina;
        b -= 2 * mina;
        minb = b < c / 2 ? b : c / 2;
        sum += 3 * minb;
      } else {
        sum += 3 * minb;
        c -= 2 * minb;
        b -= minb;
        mina = a < b / 2 ? a : b / 2;
        sum += 3 * mina;
      }
    }
    cout << sum << "\n";
  }
  return 0;
}
