1
10 2 20
8 5 2 4 10 3 9 7 1 6
5 10
3 17
6 31
3 46
10 42
7 19
9 36
7 3
3 13
8 32
10 25
9 34
10 34
6 33
3 9
2 17
4 5
10 44
9 15
5 40
 1
47 1 47
40 45 19 10 44 33 47 12 2 46 16 23 3 14 21 28 31 42 22 18 35 38 24 25 36 32 4 34 5 20 37 39 6 9 1 7 29 8 17 27 30 11 13 41 15 43 26
39 25
41 24
32 30
10 6
30 13
24 35
41 17
31 31
9 44
21 8
43 23
8 5
29 13
8 4
47 20
22 10
37 27
17 39
43 23
14 42
46 19
43 24
30 31
24 35
31 13
31 32
20 9
3 2
20 9
14 7
7 3
21 36
32 30
47 19
11 43
6 2
31 31
26 12
47 20
2 1
40 24
16 40
45 21
36 28
36 28
17 38
30 31
 1
1 1 4
1
1 1
1 2
1 3
1 4
 1
10 1 1
10 4 6 5 7 9 8 1 3 2
6 10

3
2
7
10
6
7
7
7
5
1
6
6
1
9
4
4
4
1
1
3
 27
27
37
16
20
24
11
20
46
35
11
2
34
47
26
24
7
28
11
3
26
13
37
24
37
37
22
10
22
14
47
38
37
43
23
33
20
4
26
19
30
21
43
1
1
42
37
 1
-1
-1
-1
 9

/*
Problem : 
Algorithm : 
Status : 
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG cerr << "Passing Line " << __LINE__<< " in Function [" << __FUNCTION__ << "].\n";
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<class T> inline bool checkMax(T &a,const T &b) {return a < b ? a = b,1 : 0;}
template<typename T, typename...Args> inline void checkMax(T &a,const Args...arg) {checkMax(a,max(arg...));}
template<class T> inline bool checkMin(T &a,const T &b) {return a > b ? a = b,1 : 0;}
template<typename T, typename...Args> inline void checkMin(T &a,const Args...arg) {checkMin(a,min(arg...));}

namespace FastIO{
    const int SIZE = 1 << 21;
    char ch;
    char in[SIZE],*inS = in,*inT = in + SIZE;
    char out[SIZE],*outS = out,*outT = out + SIZE;

    #define flush() fwrite(out,1,outS - out,stdout), outS = out
    #define getchar() (inS == inT && (inT = (inS = in) + fread(in,1,SIZE,stdin),inS == inT) ? EOF : *inS++)
    void putchar(char c) {*outS++ = c; if(outS == outT) flush();}

    struct Flusher {~Flusher() {flush();}} flusher;

    template<typename T> inline void read(T &x){
        static int f; x = 0; f = 1; ch = getchar();
        while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();}
        while(isdigit(ch)) {x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();} x *= f;
    }

    inline void read(char* s){
        static int len; len = 0; ch = getchar();
        while(ch == '\n' || ch == ' ' || ch == '\0') ch = getchar();
        while(ch != '\n' && ch != ' ' && ch != EOF) s[len++] = ch, ch = getchar(); s[len] = '\0';
    }    

    template<typename T> inline void write(T x){
        if(!x) putchar('0');
        if(x < 0) {x = -x; putchar('-');}
        static int sta[20]; int tot = 0;
        while(x) {sta[tot++] = x % 10; x /= 10;}
        while(tot) putchar(sta[--tot] + 48);
    }

    inline void write(char c) {putchar(c);}
    template<typename T> inline void writeln(T c) {write(c); putchar('\n');}

    template<typename T,typename... Args> inline void read(T &t, Args &...args) {read(t); read(args...);}
}

using FastIO::read;
using FastIO::write;
using FastIO::writeln;

const int INF = 0x3f3f3f3f;
const ll llINF = 1e18;
const int MAXN = 6e4 + 5;
const int MAXC = 5;

int n,C,Q,T;
int cnt[MAXC][MAXN],p[MAXN];
ll comb[MAXN][MAXC],w[MAXC][MAXN * MAXC];

struct Node{
    int l,r; ll w;
    Node(int _l = 0,int _r = 0,ll _w = 0) : l(_l), r(_r), w(_w) {}
};

struct Deque{
    int head,tail;
    Node a[MAXN * MAXC * 2 + 100];

    Node& operator [] (const int &i) {return a[head + i - 1];}

    void push_front(Node u) {a[--head] = u; }
    void push_back(Node u) {a[++tail] = u;}
    void clear() {head = MAXN * MAXC + 5, tail = MAXN * MAXC + 4;}
    int size() {return tail - head + 1;}
    Deque() {clear();}
} q[MAXC];

void Init(int n){
    comb[0][0] = 1;
    for(int i = 1;i <= n;i++){
        comb[i][0] = 1;
        for(int j = 1;j <= min(MAXC - 1,i);j++)
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
    }
    for(int i = 0;i <= n;i++){
        for(int j = 1;j < MAXC;j++) comb[i][j] += comb[i][j - 1];
    }
}

ll calc(int n,int c){
    if(n <= 0) return 1;
    return comb[n - 1][c];
}

bool cmp(const Node &x,const Node &y){
    return p[x.r] < p[y.r];
}

Node GetNxt(int c,int pos,ll rk){
    int num = cnt[c][pos];
    int l = num + 1, r = q[c].size(), res = 0;
    while(l <= r){
        int mid = (l + r) >> 1;
        if(w[c][mid] - w[c][num] >= rk) res = mid, r = mid - 1;
        else l = mid + 1;
    }
    return Node(q[c][res].l,q[c][res].r,w[c][res - 1] - w[c][num]);
}

void Solve(){
    read(n,C,Q);
    for(int i = 1;i <= n;i++) read(p[i]);
    for(int c = 1;c <= C;c++){
        q[c].clear(); vector<Node> front,back; 
        for(int i = 1;i <= n;i++) cnt[c][i] = 0;
        q[c].push_back(Node(n,n,1));
        for(int i = n - 1;i >= 1;i--){
            front.clear(); back.clear();
            for(int j = 1;j <= min(c,n - i);j++){
                if(p[i + j] < p[i])
                    front.emplace_back(i,i + j,calc(n - i - j,c - j)), cnt[c][i + 1] += 1;
                else back.emplace_back(i,i + j,calc(n - i - j,c - j));
            }
            sort(front.begin(),front.end(),cmp); reverse(front.begin(),front.end());
            sort(back.begin(),back.end(),cmp);
            for(auto x : front) q[c].push_front(x);
            for(auto x : back) q[c].push_back(x);
        }
        for(int i = 1;i <= n;i++) cnt[c][i] += cnt[c][i - 1];
        for(int i = 1, sz = q[c].size();i <= sz;i++)
            w[c][i] = w[c][i - 1] + q[c][i].w;
    }
    while(Q--){
        int pos; ll rk; read(pos,rk);
        if(rk > calc(n,C)) {writeln(-1); continue;}
        int x = 1, c = C; vector<pii> vec; vec.clear();
        while(c && x <= n){
            Node res = GetNxt(c,x,rk);
            rk -= res.w; c -= (res.r - res.l); x = res.r + 1;
            vec.emplace_back(res.l,res.r);
        }
        int flag = 0;
        for(auto pi : vec){
            if(pos >= pi.first && pos <= pi.second){
                writeln(p[pi.second - pos + pi.first]);
                flag = 1; break;
            }
        }
        if(!flag) writeln(p[pos]);
    }
}

int main(){
//    freopen("data.in","r",stdin);
//    freopen("data.out","w",stdout);
    Init(MAXN - 1); read(T); while(T--) Solve();
    return 0;
}
