#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if (b >= c / 2 + (c % 2 != 0)) {
      ans += c / 2 + c - (c % 2 != 0);
      b -= c / 2;
      ans += b / 2 + b - (b % 2 != 0);
      cout << ans << endl;
    } else
      cout << b * 2 << endl;
  }
  return 0;
}
