#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, p1 = 0, p2 = 0;
    cin >> a >> b >> c;
    while (1) {
      if (a > 0 && b > 1) {
        a--;
        b -= 2;
        ans += 3;
        p1 = 1;
      }
      if (b > 0 && c > 1) {
        b--;
        c -= 2;
        ans += 3;
        p2 = 1;
      }
      if (!p1 && !p2) break;
      p1 = 0;
      p2 = 0;
    }
    cout << ans << '\n';
  }
  return 0;
}
