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