#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, x, y, sum = 0;
  cin >> n;
  while (n--) {
    cin >> a >> b >> c;
    if (a >= 1 && c > 1 && b >= 1) {
      if (b < c) {
        sum += (c / 2) * 3;
        b -= c / 2;
        if (b > 1) sum += (b / 2) * 3;
      } else {
        sum += (b / 2) * 3;
        if (b % 2 == 1) sum += 3;
      }
    }
    cout << sum;
    sum = 0;
  }
  return 0;
}
