#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  int arr[q];
  for (int i = 0; i < q; i++) {
    int a, b, c;
    int sum = 0;
    cin >> a;
    cin >> b;
    cin >> c;
    int k = c / 2;
    if (b >= k) {
      sum = sum + (3 * k);
      b = b - k;
      if (b > 1) {
        int l = b / 2;
        sum = sum + (3 * l);
      }
      arr[i] = sum;
    } else {
      arr[i] = b * 3;
    }
  }
  cout << endl;
  for (int i = 0; i < q; i++) {
    cout << arr[i] << endl;
  }
}
