# 可持久化线段树——Step 1 静态区间第K大

#include <bits/stdc++.h>
using namespace std ;
bool Read ( int &x ) { char c = getchar() ; x = 0 ; bool f = 0 ; while ( !isdigit(c) ) { if ( c == '-' ) f = 1 ; if ( c == EOF ) return false ; c = getchar() ; } while ( isdigit(c) ) { x = 10 * x + c - '0' ; c = getchar() ; } if (f) x = -x ;return true ; }
void Print ( int x ) { int len = 0, a[50] ; if ( x == 0 ) { putchar('0') ; return ; } if ( x < 0 ) { putchar('-') ; x = -x ; } while (x) { a[++len] = x%10 ; x /= 10 ; } while (len) putchar(a[len--]+'0') ;}

const int maxn = 100010 ;
int n, m, rt[maxn], Rank[maxn], cnt ;
struct node {
int l, r, v ;
} tree[maxn<<5] ;
struct nodd {
int v, id ;
friend bool operator < ( nodd a, nodd b ) {
return a.v == b.v ? a.id < b.id : a.v < b.v ;
}
} a[maxn] ;

void insert ( int K, int& x, int l, int r ) {
tree[++cnt] = tree[x] ;
x = cnt ;
++ tree[x].v ;
int mid = l+r >> 1 ;
if ( l == r ) return ;
if ( K <= mid ) insert ( K, x[tree].l, l, mid ) ;
else insert ( K, x[tree].r, mid+1, r ) ;
}

int query ( int rt1, int rt2, int l, int r, int K ) {
if ( l == r ) return l ;
int mid = l+r >> 1 ;
int num = tree[rt2].l[tree].v - tree[rt1].l[tree].v ;
if ( K <= num ) return query ( rt1[tree].l, rt2[tree].l, l, mid, K ) ;
else return query ( rt1[tree].r, rt2[tree].r, mid+1, r, K-num ) ;
}

int main() {
int i, j, k, x, y ;
for ( i = 1 ; i <= n ; i ++ ) {
a[i].id = i ;
}
sort ( a+1, a+n+1 ) ;
for ( i = 1 ; i <= n ; i ++ )
a[i].id[Rank] = i ;

for ( i = 1 ; i <= n ; i ++ ) {
rt[i] = rt[i-1] ;
insert ( Rank[i], rt[i], 1, n ) ;
}

while ( m-- ) {
}