#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  cin.tie(0);
  for (int i = 1; i <= t; ++i) {
    int a, b, c, ans = 0, kol;
    cin >> a >> b >> c;
    kol = c / 2;
    if (b == 0) {
      cout << 0;
      continue;
    }
    if (kol <= b) {
      ans += (kol * 2 + kol);
      b -= kol;
    } else {
      ans += b * 2 + b;
      b -= kol;
    }
    if (b == 0 || a == 0) {
      cout << ans << '\n';
      continue;
    }
    kol = b / 2;
    if (kol <= a)
      ans += (kol * 2 + kol);
    else
      kol += a * 2 + a;
    cout << ans << '\n';
  }
  return 0;
}
