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