#include #ifdef SHO_LOCAL #include "debug.h" #else #define debug(...) \ {} #endif using namespace std; void solution() { long long a, b, c; cin >> a >> b >> c; long long ans = 0; long long t = min(c, a); if (a <= c) { c -= a; a = 0; } else { a -= c; c = 0; } ans += t * 2; t = min(a, b); ans += t; cout << ans << '\n'; } int main() { iostream::sync_with_stdio(0), cin.tie(0), cout.tie(0); int TT; cin >> TT; for (int tc = 1; tc <= TT; tc++) { // cout << "Case #" << tc << ": " << solution() << '\n'; solution(); } return 0; }