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