#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, x, y, z, sum = 0;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> x >> y >> z;
    sum = 0;
    int tx = x, ty = y, tz = z;
    while (ty > 0) {
      if (tz > 1) {
        tz -= 2;
        ty -= 1;
        sum += 3;
      } else {
        ty -= 2;
        tx -= 1;
        sum += 3;
      }
    }
    cout << sum;
  }
}
