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