#include <bits/stdc++.h>
using namespace std;
int n, a, b, c;
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d%d", &a, &b, &c);
    int ans = 0;
    if (!b) {
      printf("0\n");
      continue;
    }
    ans += min(b, c / 2) * 3;
    if (b > c / 2) b -= c / 2;
    ans += 3 * min(b / 2, a);
    printf("%d\n", ans);
  }
}
