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