#include <bits/stdc++.h>
using namespace std;
const int N = (1e5 + 99999);
const int mod = 1e9 + 7;
int q;
void turbo() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
void file() {
  freopen("name.in", "r", stdin);
  freopen("name.out", "w", stdout);
}
void solve() {
  int a, b, c, ans = 0;
  cin >> a >> b >> c;
  if (c > b) {
    while (c >= 2 && b >= 1) {
      ans += 1 + 2;
      b -= 1;
      c -= 2;
    }
    while (b >= 2 && a >= 1) {
      ans += 1 + 2;
      b -= 2;
      a -= 1;
    }
  } else {
    while (b >= 2 && a >= 1) {
      ans += 1 + 2;
      b -= 2;
      a -= 1;
    }
    while (c >= 2 && b >= 1) {
      ans += 1 + 2;
      b -= 1;
      c -= 2;
    }
  }
  cout << ans << endl;
}
int main() {
  turbo();
  cin >> q;
  while (q--) {
    solve();
  }
}
