#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    int sum = 0;
    if (b == 0 || (a == 0 && c == 0))
      cout << 0 << endl;
    else if (c > b) {
      int i = 0;
      while (2 * (i + 1) <= c && i <= b) {
        i++;
      }
      if (i * 2 > c || i > b) i--;
      sum += (i * 3);
      b = b - i;
      c = c - (2 * i);
      i = 0;
      while ((2 * (i + 1)) <= b && i <= a) {
        i++;
      }
      if (i * 2 > b || i > a) i--;
      sum += (3 * i);
      cout << sum << endl;
    } else {
      int i = 0;
      while (2 * (i + 1) <= b && i <= a) {
        i++;
      }
      if ((i * 2) > b || i > a) i--;
      sum += (3 * i);
      a = a - i;
      b = b - (2 * i);
      i = 0;
      while (2 * (i + 1) <= c && i <= b) {
        i++;
      }
      if (i * 2 > c || i > b) i--;
      sum += (i * 3);
      cout << sum << endl;
    }
  }
}
