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