#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a;
  cin >> a;
  for (long long int i = 0; i < a; i++) {
    long long int b, c, d;
    cin >> b >> c >> d;
    long long int x, y, ma = 0, ans;
    for (long long int x = 0; x <= b; x++) {
      y = c - 2 * (x);
      if ((2 * y) <= d && y >= 0) {
        ans = 3 * (x) + 3 * (y);
        if (ans > ma) {
          ma = ans;
        }
      }
    }
    cout << ma << "\n";
  }
}
