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