#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = 2012345678;
const int N = 100010;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    int ans1 = min(a, b / 2) * 3;
    ans1 += min(b - ans1 * 2 / 3, c / 2);
    int ans2 = min(b, c / 2) * 3;
    ans2 += min(b - ans2 / 6, a);
    cout << max(ans1, ans2) << endl;
  }
}
