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