#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    int ans1 = 0, ans2 = 0;
    int a1 = a, b1 = b, c1 = c;
    if (2 * a1 <= b1) {
      ans1 += (a1 + 2 * b1);
      b1 = b1 - 2 * a1;
    } else {
      ans1 += b1 / 2 + 2 * (b1 / 2);
      b1 = b1 - 2 * (b1 / 2);
    }
    if (2 * b1 <= c1) {
      ans1 += (b1 + b1 * 2);
    } else {
      ans1 += c1 / 2 + 2 * (c1 / 2);
    }
    a1 = a, b1 = b, c1 = c;
    if (2 * b1 <= c1) {
      ans2 += (b1 + b1 * 2);
      b1 = 0;
    } else {
      ans2 += c1 / 2 + 2 * (c1 / 2);
      b1 = b1 - (c1 / 2);
    }
    if (2 * a1 <= b1) {
      ans2 += (a1 + 2 * b1);
    } else {
      ans2 += b1 / 2 + 2 * (b1 / 2);
    }
    cout << std::max(ans1, ans2) << "\n";
  }
  return 0;
}
