#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t = 0;
  cin >> t;
  for (long long i = 0; i < t; i++) {
    long long a = 0, b = 0, c = 0, t = 0;
    cin >> a >> b >> c;
    int d = c / 2;
    if (b >= d) {
      t += (d * 3);
      b -= d;
    } else {
      t += (b * 3);
      b = 0;
    }
    d = b / 2;
    if (a >= d) t += (d * 3);
    cout << t << endl;
  }
}
