#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b, c, ans;
    cin >> a >> b >> c;
    if (b == 0)
      cout << "0" << endl;
    else if (b == 1 && c >= 2)
      cout << "3" << endl;
    else if (b == 1 && c < 2)
      cout << "0" << endl;
    else if (b >= 2 && c < 2 && a >= 1) {
      long long int temp = b / 2;
      a = a - temp;
      if (a >= 0)
        ans = 3 * temp;
      else
        ans = 3 * a;
      cout << ans << endl;
    } else if (b >= 2 && c >= 2 && a < 1) {
      long long int temp = c / 2;
      b = b - temp;
      if (b >= 0)
        ans = 3 * temp;
      else
        ans = 3 * b;
      cout << ans << endl;
    } else if (b >= 2 && c >= 2 && a >= 1) {
      long long int temp = c / 2;
      if (b >= temp) {
        b = b - temp;
        ans = 3 * temp;
      } else {
        ans = 3 * b;
        b = 0;
      }
      long long int x = b / 2;
      ans = ans + 3 * x;
      cout << ans << endl;
    } else if (b >= 2 && a < 1 && c < 2)
      cout << "0" << endl;
  }
  return 0;
}
