#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    int t1 = min(a, b / 2);
    int t2 = min(b, c / 2);
    if (t1 > t2) {
      ans += t1 + t1 * 2;
      a -= t1;
      b -= 2 * t1;
    } else {
      ans += t2 + t2 * 2;
      b -= t2;
      c -= 2 * t2;
    }
    t1 = min(a, b / 2);
    t2 = min(b, c / 2);
    if (t1 > t2) {
      ans += t1 + t1 * 2;
      a -= t1;
      b -= 2 * t1;
    } else {
      ans += t2 + t2 * 2;
      b -= t2;
      c -= 2 * t2;
    }
    cout << ans << endl;
  }
  return 0;
}
