#include <bits/stdc++.h>
using namespace std;
template <typename type>
type __lcm(type n1, type n2) {
  return n1 * (n2 / __gcd(n1, n2));
}
long long nCr(int n, int r) {
  int f1 = r, f2 = n - r;
  if (f2 > f1) swap(f2, f1);
  long long result = 1;
  for (int i = 1; i <= f2; i++) {
    result *= (i + f1);
    result /= i;
  }
  return result;
}
long long nPr(int n, int r, long long mod = 0) {
  long long result = 1;
  for (int i = n - r + 1; i <= n; i++) {
    result *= i;
    if (mod) result %= mod;
  }
  return result;
}
long long factorial(int n, long long modulo = 0) {
  if (n == 0) return 1;
  if (modulo)
    return (n * factorial(n - 1)) % modulo;
  else
    return n * factorial(n - 1);
}
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n) {
  n += 5;
  isPrime = new bool[n];
  memset(isPrime, 1, n);
  int sq = sqrt(n);
  isPrime[0] = isPrime[1] = false;
  for (int i = 4; i < n; i += 2) isPrime[i] = false;
  for (int i = 3; i <= sq; i += 2)
    if (isPrime[i])
      for (int j = i * i; j < n; j += (i << 1)) isPrime[j] = false;
  int primeCount = 1;
  for (int i = 3; i < n; i += 2) primeCount += (isPrime[i]);
  primes = new int[primeCount];
  primes[pidx++] = 2;
  for (int i = 3; i < n; i += 2)
    if (isPrime[i]) primes[pidx++] = i;
}
int *isbPrime = NULL;
void bitwise_sieve(int n) {
  n += 5;
  int array_size = (n >> 5);
  isbPrime = new int[array_size];
  memset(isbPrime, 0, n >> 3);
  int sq = sqrt(n);
  (isbPrime[0 >> 5] = isbPrime[0 >> 5] or (1 << (0 % 32)));
  (isbPrime[1 >> 5] = isbPrime[1 >> 5] or (1 << (1 % 32)));
  for (int i = 4; i < 64; i += 2)
    (isbPrime[i >> 5] = isbPrime[i >> 5] or (1 << (i % 32)));
  for (int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
  for (int i = 3; i <= sq; i += 2)
    if (!(isbPrime[i >> 5] & (1 << (i % 32))))
      for (int j = i * i; j < n; j += (i << 1))
        (isbPrime[j >> 5] = isbPrime[j >> 5] or (1 << (j % 32)));
}
void f();
int main() {
  int t = 1;
  scanf("%d", &(t));
  for (int(i) = (1); (i) <= (t); (i)++) {
    f();
  }
  return 0;
}
void f() {
  int a, b, c;
  cin >> a >> b >> c;
  int sum = 0;
  if (b < c) {
    int take = min(b, c / 2);
    sum += take * 3;
    b -= take;
    c -= take * 2;
    take = min(a, b / 2);
    a -= take;
    b -= take * 2;
    sum += take * 3;
  } else {
    int take = min(a, b / 2);
    a -= take;
    b -= take * 2;
    sum += take * 3;
    take = min(b, c / 2);
    sum += take * 3;
  }
  cout << sum << '\n';
}
