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