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