#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
inline int read() {
  int x = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) w |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return w ? -x : x;
}
int t;
int main() {
  t = read();
  while (t--) {
    int a = read(), b = read(), c = read(), ans = 0;
    int t = c / 2;
    if (t >= b) {
      ans += b + b * 2;
    } else {
      ans += t + t * 2;
      b -= t;
      ans += b + min(b / 2, a);
    }
    cout << ans << endl;
  }
  return 0;
}
