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