#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    float a, b, c;
    int cum = 0, sum = 0;
    cin >> a >> b >> c;
    float y = min(floor(c / 2), b);
    cum = y * 2 + y;
    float z = min(floor(b - y) / 2, a);
    cum = cum + z + z * 2;
    float k = min(floor(b / 2), a);
    sum = k * 2 + k;
    float i = min(b - k, floor(c / 2));
    sum = i * 2 + i;
    cout << max(sum, cum) << endl;
  }
  return 0;
}
