#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 10;
int a[MAXN];
long long int mod = 1000 * 1000 * 1000 + 7;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    int t = a, second = b, d = b;
    int ans1 = min(c / 2, b);
    b -= ans1;
    ans1 += min(b / 2, a);
    int ans2 = min(t, second / 2);
    second -= ans2 * 2;
    ans2 += min(second, d / 2);
    cout << max(ans1, ans2) * 3 << endl;
  }
  return 0;
}
