#include <bits/stdc++.h>
using namespace std;
int tirar(int a, int b, int c, int flag) {
  int cont1 = 0;
  while (a > 0 && b > 1) {
    a -= 1;
    b -= 2;
    cont1 += 3;
  }
  while (b > 0 && c > 1) {
    if (flag) {
      b -= 1;
      c -= 2;
    } else {
      c -= 1;
      b -= 2;
    }
    cont1 += 3;
  }
  return cont1;
}
int main() {
  int t, a, b, c, i, cont1;
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> a >> b >> c;
    if (a > c) {
      cont1 = tirar(a, b, c, 1);
    } else {
      cont1 = tirar(b, c, a, 0);
    }
    printf("%d\n", cont1);
  }
  return 0;
}
