#include <bits/stdc++.h>
int main() {
  int kase, sum, i = 0;
  scanf("%d", &kase);
  int d[1000];
  memset(d, 0, sizeof(d));
  int times = 0, a, b, c;
  while (times < kase) {
    times++;
    scanf("%d %d %d", &a, &b, &c);
    if (b >= 1) {
      if (a < fabs((int)(1.0 * b - c / 2))) {
        sum = (c / 2) * 3 + a;
      } else {
        sum = (c / 2) * 3 + ((int)(1.0 * b - c / 2) / 2) * 3;
      }
    } else {
      sum = 0;
    }
    d[i] = sum;
    i++;
  }
  for (i = 0; i < kase; i++) {
    if (i <= kase - 2) {
      printf("%d\n", d[i]);
    } else
      printf("%d", d[i]);
  }
  return 0;
}
