#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b, c, ans;
  cin >> t;
  while (t--) {
    ans = 0;
    cin >> a >> b >> c;
    while (b > 2 && c >= 2) {
      ans += 3;
      b--;
      c -= 2;
    }
    if (a == 0)
      while (b >= 1 && c >= 2) {
        ans += 3;
        b--;
        c -= 2;
      }
    while (a > 0 && b >= 2) {
      ans += 3;
      a--;
      b -= 2;
    }
    cout << ans << endl;
  }
  return 0;
}
