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