#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");
    else
      cout << min(a + c / 2, b) * 3 << endl;
  }
}
