For this Question: You are given an array of size n consisting of unique integers and an integer k. A function f is defined as follows:

f(i) = Minimum j such that subarray a<sub>i</sub>, a<sub>i+1</sub>, ., a<sub>j</sub> have k elements strictly greater than a<sub>i</sub>
          and -1 (if no such j exists)

Your task is to calculate f(i) for all 1 ≤ i ≤ n.The first line contains an integer t (1 <= T <= 10<sup>5</sup>) - the number of test cases.

The first line of each test case contains two integers n and k (1 <= n <= 10<sup>5</sup>, 1 <= k <= n).

The second line of each test case contains n integers a<sub>1</sub>, a<sub>2</sub>, …a<sub>n</sub> (−10<sup>9</sup> <= a<sub>i</sub> <= 10<sup>9</sup>).

It is guaranteed that elements in a given array are unique.
It is guaranteed that the sum of n over all test cases does not exceed 2 * 10<sup>5</sup>.For each test case, print a separate line containing space-separated n integers f(1), f(2),. , f(n).Sample Input 1:
1
3 1
2 1 3

Sample Output 1:
2 2 -1

Explanation:
For index 0, the element at index 2 is the first element greater than 2.
For index 1, the element at index 2 is the first element greater than 1.
For index 2, no such index exists.
, I have written this Solution Code: #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define endl '\n'
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define sz(x) ((ll)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x = min(x,y)
#define maxi(x,y) x = max(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;
uniform_int_distribution<int> rng(0, 1e9);
 
// DEBUG FUNCTIONS START
void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void deb() {cerr << "\n";}
template <typename T, typename... V> void deb(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; deb(v...);}
// DEBUG FUNCTIONS END
 
 
const int N = 2e5 + 5;
 
 
void solve(){
    
    
    int n, k;
    cin >> n >> k;
 
    vi a(n);
    rep(i,0,n){
        cin >> a[i];
    }
 
    vi b = a;
    sort(all(b));
 
    vi pos(n);
    ordered_set<int> s;
 
    rep(i,0,n){
        a[i] = lb(all(b), a[i]) - b.begin();
        pos[a[i]] = i;
        s.insert(i);
    }
 
 
    vi res(n, -1);
 
    rep(i,0,n){
 
        int position = pos[i];
        int idx = s.order_of_key(position);
 
        if(sz(s) > idx + k){
            res[position] = *s.find_by_order(idx + k);
        }
 
        s.erase(position);
    }
 
 
    rep(i,0,n){
        cout << res[i] << " ";
    }
    cout << endl;
 
 
 
 
    
 
}
 
 
 
 
signed main(){
    
    ios_base::sync_with_stdio(0), cin.tie(0);
    cout << fixed << setprecision(15);
    //freopen ("03.txt","r",stdin);
    //freopen ("3.txt","w",stdout);
    int t = 1;
    cin >> t;
 
    while (t--)
        solve();
    return 0;
}
 
int powm(int a, int b){
    int res = 1;
    while (b) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
 
, In this Programming Language: C++, Now tell me if this Code is compilable or not?