#include <bits/stdc++.h>
using namespace std;
int t;
int a, b, c;
long long k = 0;
void func(int s) {
  if (s == 1) {
    if (a >= b / 2) {
      k = k + b / 2 + (b / 2) * 2;
      b %= 2;
    } else {
      k = k + 3 * a;
      b -= 2 * a;
    }
    if (b >= c / 2) {
      k = k + c / 2 + (c / 2) * 2;
    } else {
      k = k + 3 * b;
    }
    cout << k << endl;
  }
  if (s == 2) {
    if (b >= c / 2) {
      k = k + c / 2 + (c / 2) * 2;
      b -= c / 2;
    } else {
      k = k + 3 * b;
      b = 0;
    }
    if (a >= b / 2) {
      k = k + b / 2 + (b / 2) * 2;
    } else {
      k = k + 3 * a;
    }
    cout << k << endl;
  }
}
int main() {
  cin >> t;
  int i, j;
  while (t--) {
    cin >> a >> b >> c;
    k = 0;
    if (b > c) {
      func(1);
    } else {
      func(2);
    }
  }
  return 0;
}
