#include <bits/stdc++.h>
using namespace std;
int totalstone(int a, int b, int c) {
  if (b == 0) return 0;
  int sum = 0;
  while (c) {
    if (c >= 2) {
      sum += 2;
      c = c - 2;
    } else
      break;
    if (b >= 1) {
      sum += 1;
      b = b - 1;
    }
    if (b == 0 || c == 0) break;
  }
  while (b) {
    if (b >= 2) {
      sum += 2;
      b = b - 2;
    } else
      break;
    if (a >= 1) {
      sum += 1;
      a = a - 1;
    }
    if (b >= 2) {
      sum += 2;
      b = b - 2;
    }
    if (b == 0 || a == 0) break;
  }
  return sum;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    cout << totalstone(a, b, c) << " ";
  }
  return 0;
}
