#include <bits/stdc++.h>
int main(void) {
  int t, k, count, a, b, c, pick_from_a, pick_from_b;
  scanf("%d", &t);
  while (t) {
    scanf("%d %d %d", &a, &b, &c);
    count = 0;
    if (2 * b > c) {
      count = 3 * (c / 2);
      b = b - c / 2;
      if (2 * a > b) {
        count = count + 3 * (b / 2);
      } else {
        count = count + 3 * a;
      }
    } else {
      count = count * 3 * b;
    }
    printf("%d\n", count);
    t--;
  }
  return 0;
}
