#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int N = 2e5 + 123;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    if (a > c) {
      while (a > 0 && b > 1) {
        cnt += 3;
        a--;
        b -= 2;
      }
      while (b > 0 && c > 1) {
        cnt += 3;
        b--;
        c -= 2;
      }
    } else {
      while (b > 0 && c > 1) {
        cnt += 3;
        b--;
        c -= 2;
      }
      while (a > 0 && b > 1) {
        cnt += 3;
        a--;
        b -= 2;
      }
    }
    cout << cnt << "\n";
  }
}
