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