#include <bits/stdc++.h>
using namespace std;
int main() {
  long t;
  cin >> t;
  while (t--) {
    long a, b, c;
    cin >> a >> b >> c;
    long answer = 0;
    b = b - min(b, c / 2);
    answer += min(b, c / 2) * 3;
    a = a - min(a, b / 2);
    answer += min(a, b / 2) * 3;
    cout << answer << endl;
  }
}
