#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    int ans = 0;
    cin >> a >> b >> c;
    if (b < c) {
      ans += min(b, c / 2);
      b -= ans;
      ans += min(a, b / 2);
      cout << ans * 3 << "\n";
    } else {
      ans += min(a, b / 2);
      b -= ans * 2;
      ans += min(b, c / 2);
      cout << ans * 3 << "\n";
    }
  }
}
