#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    int mx = 0;
    for (int i = 0; i < 101; i++) {
      if (b / 2 < i) break;
      if (a < i) break;
      int total = 0;
      total += 3 * i;
      b -= 2 * i;
      total += 3 * min(b, c / 2);
      mx = max(mx, total);
    }
    cout << mx << "\n";
  }
  return 0;
}
