#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    int x, y, z;
    x = a;
    y = b;
    z = c;
    int res = b / 2;
    int res2 = c / 2;
    int ts1 = 0;
    int ts2 = 0;
    if (a >= res) {
      ts1 += res + (res * 2);
      b = b - (res * 2);
    } else {
      ts1 += a + (a * 2);
      b = b - (a * 2);
    }
    if (b >= res2) {
      ts1 += res2 + (res * 2);
    } else {
      ts1 += b + (b * 2);
    }
    if (y >= res2) {
      ts2 += res2 + (res * 2);
      y = y - res2;
    } else {
      ts2 += y + (y * 2);
      y = 0;
    }
    if (x >= y / 2) {
      ts2 += (y / 2) + (y);
    } else {
      ts2 += x + (x * 2);
    }
    cout << max(ts1, ts2) << endl;
  }
}
