#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, stones = 0;
    cin >> a >> b >> c;
    while ((a >= 1 and b >= 2) or (b >= 1 and c >= 2)) {
      if (a >= 1 and b >= 2) {
        stones += 3;
        a = a - 1;
        b = b - 2;
      } else if (b >= 1 and c >= 2) {
        stones += 3;
        b = b - 1;
        c = c - 2;
      } else
        break;
    }
    cout << stones << endl;
  }
}
