#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    int sc = 0;
    if (c > 1 && b > 0) {
      int re = c / 2;
      sc += (re * 2);
      sc += re;
      c = c - (re * 2);
      b = b - re;
      if (b > 1 && a > 0 && a < b) {
        int re1 = a;
        sc += (re1 * 2);
        sc += re1;
        b = b - (re1 * 2);
        a = a - re1;
      } else if (a > 0 && b > 1 && a >= b) {
        int re2 = b / 2;
        sc += (re2 * 2);
        sc += re2;
        b = b - (re2 * 2);
        a = a - re2;
      }
    } else {
      if (b > 1 && a > 0 && a < b) {
        int re1 = a;
        sc += (re1 * 2);
        sc += re1;
        b = b - (re1 * 2);
        a = a - re1;
      } else if (a > 0 && b > 1 && a >= b) {
        int re2 = b / 2;
        sc += (re2 * 2);
        sc += re2;
        b = b - (re2 * 2);
        a = a - re2;
      }
    }
    cout << sc << "\n";
  }
}
