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