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