#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { long long A, B, C; cin >> A >> B >> C; long long ans = 0; ans += min(A, C) * 2LL; long long tmp = min(A, C); A -= tmp; C -= tmp; ans += min(A, B); cout << ans << endl; } return 0; }