#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
void err(istream_iterator<string> it) { cout << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ' ';
  err(++it, args...);
}
int a, b, c, p, q, r, t;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> a >> b >> c;
    p = c / 2 * 2;
    if (b >= c / 2)
      q = c / 2, b -= c / 2;
    else
      p = 0, q = 0;
    if (b >= 2 and a >= 1) {
      q += b / 2 * 2;
      r = b / 2;
      b -= b / 2 * 2;
    }
    if (p == 0 and q == 0)
      cout << 0 << endl;
    else
      cout << p + q + r << endl;
  }
}
