#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, n, a, b, c, s1, s2, s3, sum;
  cin >> t;
  while (t--) {
    sum = 0;
    s1 = 0;
    cin >> a >> b >> c;
    for (long long i = 0; i < b + 1; i++) {
      s1 = 0;
      if (2 * i > c) break;
      s1 += (3 * i);
      s2 = b - i;
      if (s2 <= 2 * a)
        s1 += (3 * s2 / 2);
      else
        s1 += (3 * a);
      sum = max(sum, s1);
    }
    cout << sum << "\n";
  }
  return 0;
}
