#include <bits/stdc++.h>
using namespace std;
int n, x, y, z;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x >> y >> z;
    int sum = 0;
    if (x == 0 || y == 0 || z == 0) {
      cout << 0 << endl;
      continue;
    }
    while (y && z >= 2) {
      y--, z -= 2;
      sum += 3;
    }
    while (x && y >= 2) {
      x--, y -= 2;
      sum += 3;
    }
    cout << sum << endl;
  }
}
