#include <bits/stdc++.h>
using namespace std;
long n, m, x, y, t, ans, res, sum, mx, mn = 1e9, z, cnt;
string s, s1, s3, s2, s4;
set<char> st;
set<int>::iterator it;
pair<int, int> pr;
vector<int> v, v1, v2, v3, v4;
map<int, int> mp, mpp;
char a, b, c, d;
bool tr = false, fl = false;
long long used[10001];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m >> x >> y;
    if (y >= 2 and x) {
      y /= 2;
      if (y >= x) y = x;
      cnt += y * 2;
      cnt += y;
      x -= y;
    }
    if (x >= 2 and m) {
      x /= 2;
      cnt += x * 2;
      cnt += x;
    }
    cout << cnt << endl;
    cnt = 0;
  }
}
