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