#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i = b; i >= 0; i--) {
      for (int j = 0; j <= b; j++) {
        if (i + j > b) continue;
        int t = 0;
        if (i / 2 <= a && a) t += i + i / 2;
        if (j * 2 <= c) t += j + 2 * j;
        ans = max(ans, t);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
