#include <bits/stdc++.h>
int main() {
  int ans = 0;
  int t, a, b, c;
  std::cin >> t;
  for (int i = 0; i < t; i++) {
    std::cin >> a >> b >> c;
    if (c > b) {
      int interm1 = c / 2;
      if (b >= interm1) {
        b -= interm1;
      } else {
        interm1 = b;
        b = 0;
      }
      int interm2 = b / 2;
      if (a >= interm2) {
        a -= interm2;
      } else {
        interm2 = a;
        a = 0;
      }
      ans = 3 * interm1 + 3 * interm2;
    } else {
      int interm1 = b / 2;
      if (a >= interm1) {
        a -= interm1;
      } else {
        interm1 = a;
        a = 0;
      }
      int interm2 = c / 2;
      if (b >= interm2) {
        b -= interm2;
      } else {
        interm2 = b;
        b = 0;
      }
      ans = 3 * interm1 + 3 * interm2;
    }
    std::cout << ans << std::endl;
  }
  return 0;
}
