#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, i, j, w, h, count = 0, sum = 0, total, k, T, breaks = 0, m, a,
                             b, c;
    string s;
    cin >> a >> b >> c;
    if (b > c) {
      T = min(a, b / 2);
      a = a - T;
      b = b - 2 * T;
      sum = T * 3;
      T = min(b, c / 2);
      sum = sum + T * 3;
    } else {
      T = min(b, c / 2);
      sum = T * 3;
      b = b - T;
      T = min(a, b / 2);
      a = a - T;
      b = b - 2 * T;
      sum = sum + T * 3;
    }
    cout << sum << endl;
  }
}
