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