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