/*
Jackson Simoneau
SI@UCF 2026 - Intro to Competitive Programming

Solution to Portal (D): https://codeforces.com/contest/2200/problem/D
Explanations: https://codeforces.com/blog/entry/151625
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    //Process test cases
    int t; cin >> t;
    while(t--) {
        int n, x, y;
        cin >> n >> x >> y;
        vector<int> a(n);
        for(int i = 0; i < n; i++) {
            cin >> a[i];
        }

        //Find the minimal rotation of the subarray between the portals
        //We can use the two portals to rotate this portion however we want,
        //so we will place the smallest element in front
        int minrot = 0, minv = n+1;
        for(int i = x; i < y; i++) {
            if(a[i] < minv) {
                minv = a[i];
                minrot = i;
            }
        }

        //Find the leftmost element in the rest of the array that is greater than a[minrot]
        //This will be the optimal position to insert the middle subarray
        int minpos = n;
        for(int i = n-1; i >= 0; i--) {
            //Skip the middle section here
            if(i >= x && i < y) continue;
            if(a[i] > a[minrot]) minpos = i;
        }

        //Print the portion of the array before we insert the middle section
        for(int i = 0; i < minpos; i++) {
            //Skip the middle section here
            if(i >= x && i < y) continue;
            cout << a[i] << ' ';
        }

        //Print the middle section in order, starting with the minimal position
        int cur = minrot;
        for(int i = 0; i < (y-x); i++) {
            cout << a[cur] << ' ';
            cur++;
            if(cur == y) cur = x;
        }

        //Print the portion of the array after we insert the middle section
        for(int i = minpos; i < n; i++) {
            if(i >= x && i < y) continue;
            cout << a[i] << ' ';
        }
        cout << '\n';
    }
}