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