#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    if (b < c) {
      int k = min(b, c / 2);
      ans += 3 * k;
      b -= k;
      b = max(0, b);
      k = min(a, b / 2);
      ans += 3 * k;
    } else {
      int k = min(a, b / 2);
      ans += 3 * k;
      b -= 2 * k;
      b = max(b, 0);
      ans += 3 * min(b, c / 2);
    }
    cout << ans << '\n';
  }
}
