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