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