#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i;
  cin >> t;
  for (i = 0; i < t; i++) {
    int a, b, c, s = 0;
    float x, y;
    cin >> a >> b >> c;
    x = b / 2.0;
    y = c / 2.0;
    if (x > y) {
      if (x - y >= 1) {
        while (a >= 1 && b >= 2) {
          s = s + 3;
          a = a - 1;
          b = b - 2;
        }
        while (b >= 1 && c >= 2) {
          s = s + 3;
          b = b - 1;
          c = c - 2;
        }
      } else
        goto XX;
    } else {
    XX:
      while (b >= 1 && c >= 2) {
        s = s + 3;
        b = b - 1;
        c = c - 2;
      }
      while (a >= 1 && b >= 2) {
        s = s + 3;
        a = a - 1;
        b = b - 2;
      }
    }
    cout << s << endl;
  }
  return 0;
}
