#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  cin >> i;
  j = 1;
  while (j <= i) {
    int a, b, c, sum = 0;
    cin >> a >> b >> c;
    if (b <= c) {
      while (c >= 2 && b >= 1) {
        sum = sum + 3;
        c = c - 2;
        b = b - 1;
      }
      if (b >= 2) {
        while (a >= 1 && b >= 2) {
          sum = sum + 3;
          b = b - 2;
          a = a - 1;
        }
      }
      cout << sum << endl;
    } else {
      while (a >= 1 && b >= 2) {
        sum = sum + 3;
        b = b - 2;
        a = a - 1;
      }
      if (b < 2 && b >= 1) {
        while (c >= 2 && b >= 1) {
          sum = sum + 3;
          c = c - 2;
          b = b - 1;
        }
      }
      cout << sum << endl;
    }
    j++;
  }
  return 0;
}
