#include <bits/stdc++.h>
using namespace std;
int t;
int a, b, c;
int main() {
  cin >> t;
  while (t--) {
    cin >> a >> b >> c;
    int ans = 0;
    for (int x = 0; x <= 100; x++) {
      for (int y = 0; y <= 100; y++) {
        if (2 * x + y > b || a < x || c < 2 * y) continue;
        ans = max(ans, x + b + 2 * y);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
