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