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