#include <iostream>
using namespace std;
int main() {
int q = 0;
cin >> q;
while (q--)
{
int a, b, c;
cin >> a >> b >> c;
int ret = min(a, min(b, c)) * 2;
int t = b - ret / 2;
if (t < 2) cout << ret << endl;
else cout << ret + t - 1 << endl;
}
return 0;
}
class Solution {
public:
int m, n;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
queue<pair<int, int>> q;
bool vis[1001][1001];
int ret;
void bfs(vector<vector<int> >& grid)
{
while (!q.empty()) {
int sz = q.size();
while (sz--)
{
auto [a, b] = q.front();
q.pop();
for (int k = 0; k < 4; k++)
{
int x = a + dx[k], y = b + dy[k];
if (x >= 0 && x < m && y >= 0 && y < n && grid[x][y] == 1) {
grid[x][y] = 2;
q.push({x, y});
}
}
}
ret++;
}
}
int rotApple(vector<vector<int> >& grid)
{
// 第一次进去不算
ret = -1;
m = grid.size(), n = grid[0].size();
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
{
if (grid[i][j] == 2)
{
q.push({i, j});
}
}
bfs(grid);
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
{
if (grid[i][j] == 1)
{
return -1;
}
}
return ret;
}
};
};