#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int N = 1e6 + 5, mod = 1e9 + 9;
int main() {
  int t;
  cin >> t;
  int a, b, c;
  while (t--) {
    cin >> a >> b >> c;
    if (!b) {
      puts("0");
      continue;
    }
    int ans = 0;
    int x;
    x = c / 2;
    c -= x;
    b -= x;
    ans = 3 * x;
    ans += min(a, b / 2) * 3;
    cout << ans << endl;
  }
}
