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