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