#include <bits/stdc++.h>
int main() {
  int t, a, b, c, a1, b1, c1, stone1, stone2, stone = 0;
  scanf("%d", &t);
  for (int i = 0; i <= t; i++) {
    scanf("%d%d%d", &a, &b, &c);
    c1 = c / 2;
    if (b >= c1) {
      stone1 = c1 * 2 + c1;
      b1 = b - c1;
      if (b1 / 2 != 0) {
        if (a >= (b1 / 2)) {
          stone2 = (b1 / 2) * 2 + b1 / 2;
        }
      }
      stone = stone1 + stone2;
    }
    printf("%d\n", stone);
    stone = 0;
  }
  return 0;
}
