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