#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
const int MAX2 = 1e9;
const long long MAX3 = 1e12;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, sum = 0;
    cin >> a >> b >> c;
    if (c > b) {
      while (b >= 1 && c >= 2) {
        b -= 1;
        c -= 2;
        sum += 3;
      }
      while (a >= 1 && b >= 2) {
        a -= 1;
        b -= 2;
        sum += 3;
      }
    } else {
      while (a >= 1 && b >= 2) {
        a -= 1;
        b -= 2;
        sum += 3;
      }
      while (b >= 1 && c >= 2) {
        b -= 1;
        c -= 2;
        sum += 3;
      }
    }
    cout << sum << endl;
  }
}
