#include <bits/stdc++.h>
using namespace std;
int func(int a, int b, int c);
int main() {
  int t, a, b, c, x;
  cin >> t;
  int i = 0;
  while (i < t) {
    cin >> a >> b >> c;
    x = func(a, b, c);
    cout << x << endl;
    i++;
  }
  return 0;
}
int func(int a, int b, int c) {
  int x = 0;
  int i = 2;
  while (i > 0) {
    if (b <= c / 2) {
      x += 3 * b;
      c = c - (2 * b);
      b = 0;
    }
    if (a <= b / 2) {
      x += 3 * a;
      b = b - (2 * a);
      a = 0;
    }
    if (b >= c / 2) {
      x += 3 * (c / 2);
      b = b - (c / 2);
      c = c % 2;
    }
    if (a >= b / 2) {
      x += 3 * (b / 2);
      a = a - (b / 2);
      b = b % 2;
    }
    i--;
  }
  return x;
}
