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