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