Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):

/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠟⢁⣤⡉⠻⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡏⠀⡾⣻⢿⣦⠘⣿⣷⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣾⡁⢸⣇⠻⡇⣿⢀⡾⢸⣿⣿⣦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⠿⠛⠿⣧⣀⣛⡷⣦⣷⣚⣥⠞⣹⡿⠟⠿⢿⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢀⣀⣀⠀⠀⠀⠀⠀⣾⠁⠀⣠⣶⠿⠛⢛⣛⣛⣭⣭⣴⡿⢫⡷⣦⡀⠈⠻⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢸⡿⠿⠿⣷⣤⡀⠀⣿⣤⡾⣫⣶⡿⠿⠿⠟⠛⠋⠉⠀⠙⢿⣧⡙⣷⡀⢀⣿⡇⠀⣀⣤⣶⣶⣶⣶⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⡿⠿⢿⣶⣍⠻⣄⢻⣿⢞⡷⠀⠀⠀⢠⠀⠀⣤⠀⠀⣀⠀⠙⢷⣜⣿⣛⡿⢡⡾⣟⣋⣭⣭⣿⠃⠀⠀⠀⠀⠀⠀
⢠⣶⡤⡄⠀⠀⠀⡇⠀⠀⠈⠙⢧⠙⣿⣷⠏⠀⠀⠀⢠⡿⣓⣦⣤⣴⣻⢟⡇⠀⠀⠉⢻⣿⢰⣿⠾⠛⠉⠈⢩⡏⠀⠀⠀⢀⣀⣀⠀
⠸⢿⣿⠿⢷⣆⠀⢿⠀⠀⠀⠀⠈⣧⠸⣿⠀⠀⠀⠀⠀⠙⠛⠿⠽⠿⠓⣉⣠⣄⣀⠀⢸⣿⠿⠋⠀⠀⠀⠀⣾⠀⢀⠴⠚⣯⡟⡿⠀
⠀⠸⣿⡄⣷⡹⣇⠸⣧⡀⠀⠀⠀⠘⠂⣿⠁⠚⠋⣩⡛⠳⣶⠀⠀⢰⣾⣋⣩⣄⣉⡅⢻⣿⠀⠀⠀⠀⢀⣼⠃⣰⠋⠀⠀⣿⣧⣷⡆
⠀⠀⠈⠳⣝⢧⣿⠀⢹⡇⠀⠀⠀⠀⢀⣿⠀⠈⢿⣻⢿⣿⡇⠀⠀⠀⠸⣿⣿⡿⠋⠀⢸⣿⠀⠀⠀⠰⣿⠋⠀⣏⠀⢀⡼⠟⣩⡟⠀
⠀⠀⠀⣀⡈⢧⢸⠀⠘⣿⡀⠀⠀⠀⢸⣿⠀⠀⠀⠈⠉⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⢸⡿⠀⠀⠀⠀⣿⠀⠀⣿⠞⠛⠛⠛⠉⠀⠀
⠀⠀⢰⣏⠙⠻⢿⣧⡀⢻⣧⠀⠀⠀⣸⣿⣇⠀⠀⠀⠀⠀⠀⠈⠛⠃⠀⠀⠀⠀⠀⢀⣿⠃⠀⠀⠀⢸⣿⠀⣀⣽⠶⢾⣷⣀⠀⠀⠀
⠀⢠⡿⠻⣷⡤⠀⠉⠻⣦⡝⠷⣦⣾⠏⢘⣿⣆⠀⠀⠀⠀⠀⠀⣿⡆⠀⠀⠀⠀⢠⡿⠛⣧⡀⢀⣴⣿⣿⡾⠋⢀⣠⡞⠋⢻⣷⡀⠀
⠀⣿⠀⠀⢿⣇⠀⠀⠀⢸⣷⡾⠛⢁⣴⠟⠙⣿⣿⣦⠀⠀⠀⠀⣿⡇⠀⠀⠀⢠⢿⣶⢶⣿⠛⢿⣿⠋⢿⡇⠀⠀⠙⣿⠀⠀⣿⡇⠀
⠀⣿⣧⣠⡶⢿⣅⠀⠀⣸⡟⠀⠀⣾⡇⠀⠀⣿⣷⢿⣧⠀⠀⠀⠹⣷⡀⠀⠀⣿⡜⢿⣦⣙⣷⡄⢻⣷⠘⠇⠀⠀⠴⠟⠀⢠⡿⠀⠀
⠀⠘⣿⠏⠀⠀⠹⣷⣜⠋⡀⠀⠀⣿⣧⣄⠀⠈⠀⠈⣿⡆⠀⠀⠀⢻⣧⠀⠀⠹⣿⣤⣀⣈⣁⣀⣬⡿⠷⢶⣶⣤⣀⢀⣴⢿⣿⡆⠀
⠀⢸⡟⠀⠀⠀⣀⣿⣿⢿⣧⠀⢀⣼⠟⠁⠀⠀⠀⠀⠸⣿⡀⠀⠀⠀⠙⢷⣄⡀⠉⠛⠛⠛⢛⣩⣤⠤⠀⣀⠀⠙⢿⣧⣀⣴⠟⠀⠀
⠀⢸⣇⢠⡴⠛⢛⣽⡇⠸⣿⠀⣼⠁⠀⠀⠀⠀⠀⠀⠀⠹⣿⣄⠀⠀⠀⠀⠈⠉⠓⠒⠒⠛⠉⠁⢀⣴⡟⠛⢷⣆⠈⣿⠉⠀⠀⠀⠀
⠀⠘⣿⡏⠀⣴⠟⠋⠁⠀⣿⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⣰⠏⣿⣷⣤⣀⠀⠀⠀⠀⠀⠀⣀⣤⣶⣿⣿⣄⠀⠈⢉⣼⣧⣄⠀⠀⠀⠀
⠀⠀⢹⡇⢸⠿⠆⠀⠀⣸⡟⢸⡇⠀⠀⠀⠀⠀⠀⣠⠞⠁⣴⠃⠈⠙⠛⠿⠿⠷⠿⠿⠛⠋⠁⢸⣿⡌⣛⣿⡿⠋⠉⠉⠛⣷⣀⣀⡀
⠀⠀⢘⣿⣦⣀⡀⣀⡴⣿⣷⣌⣿⣦⣀⣀⣠⠴⠛⠁⣠⡞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡿⢹⣿⠛⠛⠛⠛⠛⠛⠋⢁⣼⠃
⠀⢠⣿⠋⠉⠛⠛⠉⠀⠀⠙⠿⣿⣿⣭⣉⣀⣠⣴⠞⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⡟⠁⠘⢿⣦⡀⠀⠀⠀⠀⣰⠟⠁⠀
⠀⣾⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⣭⡉⠉⠀⠀⠀⠀⠀⠀⣴⠆⠀⠀⠀⠀⠀⢀⣤⣾⡏⠀⠀⠀⠀⠙⠻⢶⣶⣶⠛⠁⠀⠀⠀
⠀⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⣷⣦⣀⠀⠀⠀⠀⠀⠀⢀⣀⣠⡶⢞⣫⡾⠋⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀
⠀⠹⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣉⠻⢿⣿⣯⣭⣭⣭⣭⡷⠾⣟⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⡟⠀⠀⠀⠀⠀
⠀⠀⠻⣿⣦⡀⠀⣀⠀⠀⠀⠀⠀⠀⢀⣀⠾⣆⠽⠚⢉⣠⡤⠼⠿⠿⣿⣿⣦⣛⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡿⠁⠀⠀⠀⠀⠀
⠀⠀⠀⠈⠛⠻⣶⣭⣓⣖⣴⢰⣖⣻⣮⡿⠛⢁⣤⠶⠋⠁⠀⠀⣠⣀⣹⡏⠙⢿⣵⠶⣀⡀⠀⠀⠀⣀⡴⣤⡾⠋⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠹⣯⣛⠛⠛⠛⠛⢉⣡⣤⣾⡟⠁⠀⠀⠀⠀⢀⣿⠛⢿⣿⣦⣀⠙⠷⣯⣙⣓⣶⣞⣯⣾⡿⢤⡴⠒⢢⣄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠈⠙⠛⠿⠿⠟⠛⠉⠀⠙⢿⣶⣤⣄⣤⣴⣾⣏⣀⣀⣹⠟⠿⠿⠷⠶⠶⠿⠛⢉⣴⣏⢽⣾⢶⠒⠒⢸⣄⣠⣤⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠛⠛⠉⠉⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠉⠉⠉⠋⠙⢛⣁⣀⣠⠼⠇
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠒⠚⠋⠀⠀⠀⠀⠀
*/
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣷⣶⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣷⡒⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⣿⣿⣿⣆⠙⡄⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣤⣤⣤⣤⣤⣤⣤⣤⠤⢄⡀⠀⠀⣿⣿⣿⣿⣿⣿⡆⠘⡄⠀⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⢿⣿⣿⣿⣿⣿⣿⣿⣦⡈⠒⢄⢸⣿⣿⣿⣿⣿⣿⡀⠱⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣦⠀⠱⣿⣿⣿⣿⣿⣿⣇⠀⢃⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⣿⣿⣿⣿⣿⣿⣷⡄⣹⣿⣿⣿⣿⣿⣿⣶⣾⣿⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣶⣿⣭⣍⡉⠙⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⢀⣠⣶⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡷⢂⣓⣶⣶⣶⣶⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⠟⢀⣴⢿⣿⣿⣿⠟⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠋⠉⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠤⠤⠤⠙⣻⣿⣿⣿⣿⣿⣿⣾⣿⣿⡏⣠⠟⡉⣾⣿⣿⠋⡠⠊⣿⡟⣹⣿⢿⣿⣿⣿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣶⣤⣭⣤⣼⣿⢛⣿⣿⣿⣿⣻⣿⣿⠇⠐⢀⣿⣿⡷⠋⠀⢠⣿⣺⣿⣿⢺⣿⣋⣉⣉⣩⣴⣶⣤⣤⣄⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠻⠿⣿⣿⣿⣇⢻⣿⣿⡿⠿⣿⣯⡀⠀⢸⣿⠋⢀⣠⣶⠿⠿⢿⡿⠈⣾⣿⣿⣿⣿⡿⠿⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⢧⡸⣿⣿⣿⠀⠃⠻⠟⢦⢾⢣⠶⠿⠏⠀⠰⠀⣼⡇⣸⣿⣿⠟⠉⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣶⣽⣿⡟⠓⠒⠀⠀⡀⠀⠠⠤⠬⠉⠁⣰⣥⣾⣿⣿⣶⣶⣷⡶⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠹⠟⣿⣿⡄⠀⠀⠠⡇⠀⠀⠀⠀⠀⢠⡟⠛⠛⠋⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠋⠹⣷⣄⠀⠐⣊⣀⠀⠀⢀⡴⠁⠣⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣀⠤⠊⢁⡸⠀⣆⠹⣿⣧⣀⠀⠀⡠⠖⡑⠁⠀⠀⠀⠑⢄⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣦⣶⣿⣿⣟⣁⣤⣾⠟⠁⢀⣿⣆⠹⡆⠻⣿⠉⢀⠜⡰⠀⠀⠈⠑⢦⡀⠈⢾⠑⡾⠲⣄⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠖⠒⠚⠛⠛⠢⠽⢄⣘⣤⡎⠠⠿⠂⠀⠠⠴⠶⢉⡭⠃⢸⠃⠀⣿⣿⣿⠡⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⡤⠶⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣋⠁⠀⠀⠀⠀⠀⢹⡇⠀⠀⠀⠀⠒⠢⣤⠔⠁⠀⢀⡏⠀⠀⢸⣿⣿⠀⢻⡟⠑⠢⢄⡀⠀⠀⠀⠀
// ⠀⠀⠀⠀⢸⠀⠀⠀⡀⠉⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⣀⣀⡀⠀⢸⣷⡀⣀⣀⡠⠔⠊⠀⠀⢀⣠⡞⠀⠀⠀⢸⣿⡿⠀⠘⠀⠀⠀⠀⠈⠑⢤⠀⠀
// ⠀⠀⢀⣴⣿⡀⠀⠀⡇⠀⠀⠀⠈⣿⣿⣿⣿⣿⣿⣿⣿⣝⡛⠿⢿⣷⣦⣄⡀⠈⠉⠉⠁⠀⠀⠀⢀⣠⣴⣾⣿⡿⠁⠀⠀⠀⢸⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⡜⠀⠀
// ⠀⢀⣾⣿⣿⡇⠀⢰⣷⠀⢀⠀⠀⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣭⣍⣉⣉⠀⢀⣀⣤⣶⣾⣿⣿⣿⢿⠿⠁⠀⠀⠀⠀⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠉⢦⠀
// ⢀⣼⣿⣿⡿⢱⠀⢸⣿⡀⢸⣧⡀⠀⢿⣿⣿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡭⠖⠁⠀⡠⠂⠀⠀⠀⠀⠀⠀⠀⠀⢠⠀⠀⠀⢠⠃⠀⠈⣀
// ⢸⣿⣿⣿⡇⠀⢧⢸⣿⣇⢸⣿⣷⡀⠈⣿⣿⣇⠈⠛⢿⣿⣿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠟⡻⠟⠉⠀⠀⡠⠊⠀⢠⠀⠀⠀⠀⠀⠀⠀⠀⣾⡄⠀⢠⣿⠔⠁⠀⢸
// ⠈⣿⣿⣿⣷⡀⠀⢻⣿⣿⡜⣿⣿⣷⡀⠈⢿⣿⡄⠀⠀⠈⠛⠿⣿⣿⣿⣷⣶⣶⣶⡶⠖⠉⠀⣀⣤⡶⠋⠀⣠⣶⡏⠀⠀⠀⠀⠀⠀⠀⢰⣿⣧⣶⣿⣿⠖⡠⠖⠁
// ⠀⣿⣿⣷⣌⡛⠶⣼⣿⣿⣷⣿⣿⣿⣿⡄⠈⢻⣷⠀⣄⡀⠀⠀⠀⠈⠉⠛⠛⠛⠁⣀⣤⣶⣾⠟⠋⠀⣠⣾⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⠷⠊⠀⢰⠀
// ⢰⣿⣿⠀⠈⢉⡶⢿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠙⢇⠈⢿⣶⣦⣤⣀⣀⣠⣤⣶⣿⣿⡿⠛⠁⢀⣤⣾⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⣸⣿⡿⠿⠋⠙⠒⠄⠀⠉⡄
// ⣿⣿⡏⠀⠀⠁⠀⠀⠀⠉⠉⠙⢻⣿⣿⣿⣿⣷⡀⠀⠀⠀⠻⣿⣿⣿⣿⣿⠿⠿⠛⠁⠀⣀⣴⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⢠⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰  
 
// -------------------------------------------------------------------------

#include<bits/stdc++.h>
using namespace std;

#define ll long long 
#define vpll vector<pair<ll,ll>>
#define vll vector<ll>
#define vcc vector<char>
#define vdd vector<double>
#define vss vector<string>
#define vvll vector< vector<ll> >
#define all(v) v.begin(),v.end()
#define rev_sort(v) sort(all(v),greater<int>())
#define gcd __gcd
#define PI 3.14159265358979323846264338
#define max_value(a)                    *max_element(all(a))
#define min_value(a)                    *min_element(all(a))

template<typename T> istream& operator>>(istream& in, vector<T>& a) {for (auto &x : a) in >> x; return in;};
template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {for (auto &x : a) out << x << ' '; return out;};

ll mod = 1e9+7;

// int check_prime(ll x){
//     for(ll i=2; i<=sqrt(x); i++){
//         if(x%i==0) return 0;
//     }
//     return 1;
// }
// //------------------------------ math ------------------------------
// int sgn(int V) {
//     if (V < 0) {
//         return -1;
//     }
//     if (V > 0) {
//         return 1;
//     }
//     return 0;
// }
 
// int gcd(int A, int B) {
//     if (B == 0) {
//         return A;
//     }
//     return gcd(B, A % B);
// } 
 
bool isPrime(int N) {
    if (N < 2) {
        return false;
    }
    for (int i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            return false;
        }
    }
    return true;
}
 
// const ll N = 1e7;
// vector<bool> prime(N+1, true);
// void sieve(){
//     prime[0]=false;
//     prime[1]=false;
//     for (ll p = 2; p <= N; p++) {
//         if (prime[p] == true) {
//             for (ll i = p * p; i <= N; i += p)
//                 prime[i] = false;
//         }
//     }
// }

// bool comp(pair<ll, ll> p1, pair<ll, ll> p2){
//     if(p1.second<p2.second) return true;
//     if(p1.second>p2.second) return false;
//     if(p1.first<p2.first) return true;
//     return false;
// }
// //  ---------------------------------------------------
// vll dp(4020, -1);

// ll gcd(ll a, ll b)
// {
//   if (a == 0)
//     return b;
//   return gcd(b % a, a);
// }

// // Function to find gcd of array of
// // numbers
// ll findGCD(vll arr, ll n)
// {
//   ll result = arr[0];
//   for (int i = 1; i < n; i++)
//   {
//     result = gcd(arr[i], result);

//     if(result == 1)
//     {
//     return 1;
//     }
//   }
//   return result;
// }

ll fact(ll n){
    if (n == 0 || n == 1)
        return 1;
    return n * fact(n - 1);
}
// ll nCr(ll n, ll r){
//     return fact(n) / (fact(r) * fact(n - r));
// }

// ll dx[] = {0, 1, 0, -1};
// ll dy[] = {-1, 0, 1, 0};
// ll k;
// void check(ll i, ll j, vector<vector<bool>> & vis,  vector<string> & arr, ll n, ll m){
//     if(i<0 || i>=n || j<0 || j>=m || vis[i][j]==true) return;
//     vis[i][j] = true;
//     for(int x=0; x<4; x++){
//         check(i+dx[x], j+dy[x], vis, arr, n, m);
//     }
//     if(k-->0) arr[i][j] = 'X';
//     return;
// }
int firstPrimeDivisor(int n) {
    if (n % 2 == 0) return 2;

    for (int i = 3; i * i <= n; i += 2) {
        if (n % i == 0) return i;
    }
    return n;
}

void solve(){
    ll n, l, r; cin>>n>>l>>r;

    vll v(n); cin>>v;
    vll temp = v;
    sort(temp.begin()+l, temp.end());
    ll s=0,s1=0;
    for(int i=l-1; i<=r-1; i++) s += temp[i];

    temp = v;
    sort(temp.begin(), temp.begin()+r, greater<ll>());
    for(int i=r-1; i>=l-1; i--) s1 += temp[i];

    cout << min(s, s1)<< endl;

}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // sieve();
    // for(ll i=2; i*i<=N; i++) {
    //     if(prime[i]) help.push_back(i);
    // }

    int t=1; 
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

// Hare Krishna Hare Krishna 
// Krishna Krishna Hare Hare
// Hare Rama Hare Rama
// Rama Rama Hare Hare


Submission (verdict: Accepted):

/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠟⢁⣤⡉⠻⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡏⠀⡾⣻⢿⣦⠘⣿⣷⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣾⡁⢸⣇⠻⡇⣿⢀⡾⢸⣿⣿⣦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⠿⠛⠿⣧⣀⣛⡷⣦⣷⣚⣥⠞⣹⡿⠟⠿⢿⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢀⣀⣀⠀⠀⠀⠀⠀⣾⠁⠀⣠⣶⠿⠛⢛⣛⣛⣭⣭⣴⡿⢫⡷⣦⡀⠈⠻⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢸⡿⠿⠿⣷⣤⡀⠀⣿⣤⡾⣫⣶⡿⠿⠿⠟⠛⠋⠉⠀⠙⢿⣧⡙⣷⡀⢀⣿⡇⠀⣀⣤⣶⣶⣶⣶⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⡿⠿⢿⣶⣍⠻⣄⢻⣿⢞⡷⠀⠀⠀⢠⠀⠀⣤⠀⠀⣀⠀⠙⢷⣜⣿⣛⡿⢡⡾⣟⣋⣭⣭⣿⠃⠀⠀⠀⠀⠀⠀
⢠⣶⡤⡄⠀⠀⠀⡇⠀⠀⠈⠙⢧⠙⣿⣷⠏⠀⠀⠀⢠⡿⣓⣦⣤⣴⣻⢟⡇⠀⠀⠉⢻⣿⢰⣿⠾⠛⠉⠈⢩⡏⠀⠀⠀⢀⣀⣀⠀
⠸⢿⣿⠿⢷⣆⠀⢿⠀⠀⠀⠀⠈⣧⠸⣿⠀⠀⠀⠀⠀⠙⠛⠿⠽⠿⠓⣉⣠⣄⣀⠀⢸⣿⠿⠋⠀⠀⠀⠀⣾⠀⢀⠴⠚⣯⡟⡿⠀
⠀⠸⣿⡄⣷⡹⣇⠸⣧⡀⠀⠀⠀⠘⠂⣿⠁⠚⠋⣩⡛⠳⣶⠀⠀⢰⣾⣋⣩⣄⣉⡅⢻⣿⠀⠀⠀⠀⢀⣼⠃⣰⠋⠀⠀⣿⣧⣷⡆
⠀⠀⠈⠳⣝⢧⣿⠀⢹⡇⠀⠀⠀⠀⢀⣿⠀⠈⢿⣻⢿⣿⡇⠀⠀⠀⠸⣿⣿⡿⠋⠀⢸⣿⠀⠀⠀⠰⣿⠋⠀⣏⠀⢀⡼⠟⣩⡟⠀
⠀⠀⠀⣀⡈⢧⢸⠀⠘⣿⡀⠀⠀⠀⢸⣿⠀⠀⠀⠈⠉⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⢸⡿⠀⠀⠀⠀⣿⠀⠀⣿⠞⠛⠛⠛⠉⠀⠀
⠀⠀⢰⣏⠙⠻⢿⣧⡀⢻⣧⠀⠀⠀⣸⣿⣇⠀⠀⠀⠀⠀⠀⠈⠛⠃⠀⠀⠀⠀⠀⢀⣿⠃⠀⠀⠀⢸⣿⠀⣀⣽⠶⢾⣷⣀⠀⠀⠀
⠀⢠⡿⠻⣷⡤⠀⠉⠻⣦⡝⠷⣦⣾⠏⢘⣿⣆⠀⠀⠀⠀⠀⠀⣿⡆⠀⠀⠀⠀⢠⡿⠛⣧⡀⢀⣴⣿⣿⡾⠋⢀⣠⡞⠋⢻⣷⡀⠀
⠀⣿⠀⠀⢿⣇⠀⠀⠀⢸⣷⡾⠛⢁⣴⠟⠙⣿⣿⣦⠀⠀⠀⠀⣿⡇⠀⠀⠀⢠⢿⣶⢶⣿⠛⢿⣿⠋⢿⡇⠀⠀⠙⣿⠀⠀⣿⡇⠀
⠀⣿⣧⣠⡶⢿⣅⠀⠀⣸⡟⠀⠀⣾⡇⠀⠀⣿⣷⢿⣧⠀⠀⠀⠹⣷⡀⠀⠀⣿⡜⢿⣦⣙⣷⡄⢻⣷⠘⠇⠀⠀⠴⠟⠀⢠⡿⠀⠀
⠀⠘⣿⠏⠀⠀⠹⣷⣜⠋⡀⠀⠀⣿⣧⣄⠀⠈⠀⠈⣿⡆⠀⠀⠀⢻⣧⠀⠀⠹⣿⣤⣀⣈⣁⣀⣬⡿⠷⢶⣶⣤⣀⢀⣴⢿⣿⡆⠀
⠀⢸⡟⠀⠀⠀⣀⣿⣿⢿⣧⠀⢀⣼⠟⠁⠀⠀⠀⠀⠸⣿⡀⠀⠀⠀⠙⢷⣄⡀⠉⠛⠛⠛⢛⣩⣤⠤⠀⣀⠀⠙⢿⣧⣀⣴⠟⠀⠀
⠀⢸⣇⢠⡴⠛⢛⣽⡇⠸⣿⠀⣼⠁⠀⠀⠀⠀⠀⠀⠀⠹⣿⣄⠀⠀⠀⠀⠈⠉⠓⠒⠒⠛⠉⠁⢀⣴⡟⠛⢷⣆⠈⣿⠉⠀⠀⠀⠀
⠀⠘⣿⡏⠀⣴⠟⠋⠁⠀⣿⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⣰⠏⣿⣷⣤⣀⠀⠀⠀⠀⠀⠀⣀⣤⣶⣿⣿⣄⠀⠈⢉⣼⣧⣄⠀⠀⠀⠀
⠀⠀⢹⡇⢸⠿⠆⠀⠀⣸⡟⢸⡇⠀⠀⠀⠀⠀⠀⣠⠞⠁⣴⠃⠈⠙⠛⠿⠿⠷⠿⠿⠛⠋⠁⢸⣿⡌⣛⣿⡿⠋⠉⠉⠛⣷⣀⣀⡀
⠀⠀⢘⣿⣦⣀⡀⣀⡴⣿⣷⣌⣿⣦⣀⣀⣠⠴⠛⠁⣠⡞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡿⢹⣿⠛⠛⠛⠛⠛⠛⠋⢁⣼⠃
⠀⢠⣿⠋⠉⠛⠛⠉⠀⠀⠙⠿⣿⣿⣭⣉⣀⣠⣴⠞⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⡟⠁⠘⢿⣦⡀⠀⠀⠀⠀⣰⠟⠁⠀
⠀⣾⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⣭⡉⠉⠀⠀⠀⠀⠀⠀⣴⠆⠀⠀⠀⠀⠀⢀⣤⣾⡏⠀⠀⠀⠀⠙⠻⢶⣶⣶⠛⠁⠀⠀⠀
⠀⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⣷⣦⣀⠀⠀⠀⠀⠀⠀⢀⣀⣠⡶⢞⣫⡾⠋⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀
⠀⠹⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣉⠻⢿⣿⣯⣭⣭⣭⣭⡷⠾⣟⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⡟⠀⠀⠀⠀⠀
⠀⠀⠻⣿⣦⡀⠀⣀⠀⠀⠀⠀⠀⠀⢀⣀⠾⣆⠽⠚⢉⣠⡤⠼⠿⠿⣿⣿⣦⣛⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡿⠁⠀⠀⠀⠀⠀
⠀⠀⠀⠈⠛⠻⣶⣭⣓⣖⣴⢰⣖⣻⣮⡿⠛⢁⣤⠶⠋⠁⠀⠀⣠⣀⣹⡏⠙⢿⣵⠶⣀⡀⠀⠀⠀⣀⡴⣤⡾⠋⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠹⣯⣛⠛⠛⠛⠛⢉⣡⣤⣾⡟⠁⠀⠀⠀⠀⢀⣿⠛⢿⣿⣦⣀⠙⠷⣯⣙⣓⣶⣞⣯⣾⡿⢤⡴⠒⢢⣄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠈⠙⠛⠿⠿⠟⠛⠉⠀⠙⢿⣶⣤⣄⣤⣴⣾⣏⣀⣀⣹⠟⠿⠿⠷⠶⠶⠿⠛⢉⣴⣏⢽⣾⢶⠒⠒⢸⣄⣠⣤⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠛⠛⠉⠉⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠉⠉⠉⠋⠙⢛⣁⣀⣠⠼⠇
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠒⠚⠋⠀⠀⠀⠀⠀
*/
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣷⣶⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣷⡒⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⣿⣿⣿⣆⠙⡄⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣤⣤⣤⣤⣤⣤⣤⣤⠤⢄⡀⠀⠀⣿⣿⣿⣿⣿⣿⡆⠘⡄⠀⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⢿⣿⣿⣿⣿⣿⣿⣿⣦⡈⠒⢄⢸⣿⣿⣿⣿⣿⣿⡀⠱⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣦⠀⠱⣿⣿⣿⣿⣿⣿⣇⠀⢃⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⣿⣿⣿⣿⣿⣿⣷⡄⣹⣿⣿⣿⣿⣿⣿⣶⣾⣿⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣶⣿⣭⣍⡉⠙⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⢀⣠⣶⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡷⢂⣓⣶⣶⣶⣶⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⠟⢀⣴⢿⣿⣿⣿⠟⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠋⠉⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠤⠤⠤⠙⣻⣿⣿⣿⣿⣿⣿⣾⣿⣿⡏⣠⠟⡉⣾⣿⣿⠋⡠⠊⣿⡟⣹⣿⢿⣿⣿⣿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣶⣤⣭⣤⣼⣿⢛⣿⣿⣿⣿⣻⣿⣿⠇⠐⢀⣿⣿⡷⠋⠀⢠⣿⣺⣿⣿⢺⣿⣋⣉⣉⣩⣴⣶⣤⣤⣄⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠻⠿⣿⣿⣿⣇⢻⣿⣿⡿⠿⣿⣯⡀⠀⢸⣿⠋⢀⣠⣶⠿⠿⢿⡿⠈⣾⣿⣿⣿⣿⡿⠿⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⢧⡸⣿⣿⣿⠀⠃⠻⠟⢦⢾⢣⠶⠿⠏⠀⠰⠀⣼⡇⣸⣿⣿⠟⠉⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣶⣽⣿⡟⠓⠒⠀⠀⡀⠀⠠⠤⠬⠉⠁⣰⣥⣾⣿⣿⣶⣶⣷⡶⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠹⠟⣿⣿⡄⠀⠀⠠⡇⠀⠀⠀⠀⠀⢠⡟⠛⠛⠋⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠋⠹⣷⣄⠀⠐⣊⣀⠀⠀⢀⡴⠁⠣⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣀⠤⠊⢁⡸⠀⣆⠹⣿⣧⣀⠀⠀⡠⠖⡑⠁⠀⠀⠀⠑⢄⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣦⣶⣿⣿⣟⣁⣤⣾⠟⠁⢀⣿⣆⠹⡆⠻⣿⠉⢀⠜⡰⠀⠀⠈⠑⢦⡀⠈⢾⠑⡾⠲⣄⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠖⠒⠚⠛⠛⠢⠽⢄⣘⣤⡎⠠⠿⠂⠀⠠⠴⠶⢉⡭⠃⢸⠃⠀⣿⣿⣿⠡⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⡤⠶⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣋⠁⠀⠀⠀⠀⠀⢹⡇⠀⠀⠀⠀⠒⠢⣤⠔⠁⠀⢀⡏⠀⠀⢸⣿⣿⠀⢻⡟⠑⠢⢄⡀⠀⠀⠀⠀
// ⠀⠀⠀⠀⢸⠀⠀⠀⡀⠉⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⣀⣀⡀⠀⢸⣷⡀⣀⣀⡠⠔⠊⠀⠀⢀⣠⡞⠀⠀⠀⢸⣿⡿⠀⠘⠀⠀⠀⠀⠈⠑⢤⠀⠀
// ⠀⠀⢀⣴⣿⡀⠀⠀⡇⠀⠀⠀⠈⣿⣿⣿⣿⣿⣿⣿⣿⣝⡛⠿⢿⣷⣦⣄⡀⠈⠉⠉⠁⠀⠀⠀⢀⣠⣴⣾⣿⡿⠁⠀⠀⠀⢸⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⡜⠀⠀
// ⠀⢀⣾⣿⣿⡇⠀⢰⣷⠀⢀⠀⠀⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣭⣍⣉⣉⠀⢀⣀⣤⣶⣾⣿⣿⣿⢿⠿⠁⠀⠀⠀⠀⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠉⢦⠀
// ⢀⣼⣿⣿⡿⢱⠀⢸⣿⡀⢸⣧⡀⠀⢿⣿⣿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡭⠖⠁⠀⡠⠂⠀⠀⠀⠀⠀⠀⠀⠀⢠⠀⠀⠀⢠⠃⠀⠈⣀
// ⢸⣿⣿⣿⡇⠀⢧⢸⣿⣇⢸⣿⣷⡀⠈⣿⣿⣇⠈⠛⢿⣿⣿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠟⡻⠟⠉⠀⠀⡠⠊⠀⢠⠀⠀⠀⠀⠀⠀⠀⠀⣾⡄⠀⢠⣿⠔⠁⠀⢸
// ⠈⣿⣿⣿⣷⡀⠀⢻⣿⣿⡜⣿⣿⣷⡀⠈⢿⣿⡄⠀⠀⠈⠛⠿⣿⣿⣿⣷⣶⣶⣶⡶⠖⠉⠀⣀⣤⡶⠋⠀⣠⣶⡏⠀⠀⠀⠀⠀⠀⠀⢰⣿⣧⣶⣿⣿⠖⡠⠖⠁
// ⠀⣿⣿⣷⣌⡛⠶⣼⣿⣿⣷⣿⣿⣿⣿⡄⠈⢻⣷⠀⣄⡀⠀⠀⠀⠈⠉⠛⠛⠛⠁⣀⣤⣶⣾⠟⠋⠀⣠⣾⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⠷⠊⠀⢰⠀
// ⢰⣿⣿⠀⠈⢉⡶⢿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠙⢇⠈⢿⣶⣦⣤⣀⣀⣠⣤⣶⣿⣿⡿⠛⠁⢀⣤⣾⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⣸⣿⡿⠿⠋⠙⠒⠄⠀⠉⡄
// ⣿⣿⡏⠀⠀⠁⠀⠀⠀⠉⠉⠙⢻⣿⣿⣿⣿⣷⡀⠀⠀⠀⠻⣿⣿⣿⣿⣿⠿⠿⠛⠁⠀⣀⣴⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⢠⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰  
 
// -------------------------------------------------------------------------

#include<bits/stdc++.h>
using namespace std;

#define ll long long 
#define vpll vector<pair<ll,ll>>
#define vll vector<ll>
#define vcc vector<char>
#define vdd vector<double>
#define vss vector<string>
#define vvll vector< vector<ll> >
#define all(v) v.begin(),v.end()
#define rev_sort(v) sort(all(v),greater<int>())
#define gcd __gcd
#define PI 3.14159265358979323846264338
#define max_value(a)                    *max_element(all(a))
#define min_value(a)                    *min_element(all(a))

template<typename T> istream& operator>>(istream& in, vector<T>& a) {for (auto &x : a) in >> x; return in;};
template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {for (auto &x : a) out << x << ' '; return out;};

ll mod = 1e9+7;

// int check_prime(ll x){
//     for(ll i=2; i<=sqrt(x); i++){
//         if(x%i==0) return 0;
//     }
//     return 1;
// }
// //------------------------------ math ------------------------------
// int sgn(int V) {
//     if (V < 0) {
//         return -1;
//     }
//     if (V > 0) {
//         return 1;
//     }
//     return 0;
// }
 
// int gcd(int A, int B) {
//     if (B == 0) {
//         return A;
//     }
//     return gcd(B, A % B);
// } 
 
bool isPrime(int N) {
    if (N < 2) {
        return false;
    }
    for (int i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            return false;
        }
    }
    return true;
}
 
// const ll N = 1e7;
// vector<bool> prime(N+1, true);
// void sieve(){
//     prime[0]=false;
//     prime[1]=false;
//     for (ll p = 2; p <= N; p++) {
//         if (prime[p] == true) {
//             for (ll i = p * p; i <= N; i += p)
//                 prime[i] = false;
//         }
//     }
// }

// bool comp(pair<ll, ll> p1, pair<ll, ll> p2){
//     if(p1.second<p2.second) return true;
//     if(p1.second>p2.second) return false;
//     if(p1.first<p2.first) return true;
//     return false;
// }
// //  ---------------------------------------------------
// vll dp(4020, -1);

// ll gcd(ll a, ll b)
// {
//   if (a == 0)
//     return b;
//   return gcd(b % a, a);
// }

// // Function to find gcd of array of
// // numbers
// ll findGCD(vll arr, ll n)
// {
//   ll result = arr[0];
//   for (int i = 1; i < n; i++)
//   {
//     result = gcd(arr[i], result);

//     if(result == 1)
//     {
//     return 1;
//     }
//   }
//   return result;
// }

ll fact(ll n){
    if (n == 0 || n == 1)
        return 1;
    return n * fact(n - 1);
}
// ll nCr(ll n, ll r){
//     return fact(n) / (fact(r) * fact(n - r));
// }

// ll dx[] = {0, 1, 0, -1};
// ll dy[] = {-1, 0, 1, 0};
// ll k;
// void check(ll i, ll j, vector<vector<bool>> & vis,  vector<string> & arr, ll n, ll m){
//     if(i<0 || i>=n || j<0 || j>=m || vis[i][j]==true) return;
//     vis[i][j] = true;
//     for(int x=0; x<4; x++){
//         check(i+dx[x], j+dy[x], vis, arr, n, m);
//     }
//     if(k-->0) arr[i][j] = 'X';
//     return;
// }
int firstPrimeDivisor(int n) {
    if (n % 2 == 0) return 2;

    for (int i = 3; i * i <= n; i += 2) {
        if (n % i == 0) return i;
    }
    return n;
}

void solve(){
    ll n, l, r; cin>>n>>l>>r;

    vll v(n); cin>>v;
    vll temp = v;
    sort(temp.begin()+l-1, temp.end());
    ll s=0,s1=0;
    for(int i=l-1; i<=r-1; i++) s += temp[i];

    temp = v;
    sort(temp.begin(), temp.begin()+r, greater<ll>());
    for(int i=r-1; i>=l-1; i--) s1 += temp[i];

    cout << min(s, s1)<< endl;

}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // sieve();
    // for(ll i=2; i*i<=N; i++) {
    //     if(prime[i]) help.push_back(i);
    // }

    int t=1; 
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

// Hare Krishna Hare Krishna 
// Krishna Krishna Hare Hare
// Hare Rama Hare Rama
// Rama Rama Hare Hare