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