#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 count = 0;
    if (min(a, b / 2) > min(b, c / 2)) {
      count = count + 3 * min(a, b / 2);
      a = a - min(a, b / 2);
      b = b - 2 * min(a, b / 2);
      count = count + 3 * min(b, c / 2);
      b = b - min(b, c / 2);
      c = c - 2 * min(b, c / 2);
    } else {
      count = count + 3 * min(b, c / 2);
      b = b - min(b, c / 2);
      c = c - 2 * min(b, c / 2);
      count = count + 3 * min(a, b / 2);
      a = a - min(a, b / 2);
      b = b - 2 * min(a, b / 2);
    }
    cout << count << endl;
  }
}
