#include <bits/stdc++.h>   using namespace std;   int main() {     int t, T, i, n, k, d, ans, val;     cin >> T;     vector<int> id(pow(10, 6) + 1, 0);     for (t = 0; t < T; t++) {       cin >> n >> k >> d;       vector<int> v(n);       for (i = 0; i < n; i++) cin >> v[i];       ans = n;       val = 0;       for (i = 0; i < d; i++) {         id[v[i]]++;         if (id[v[i]] == 1) val++;       }       ans = val;       for (i = d; i < n; i++) {         id[v[i - d]]--;         if (id[v[i - d]] == 0) val--;         id[v[i]]++;         if (id[v[i]] == 1) val++;         ans = min(val, ans);       }       for (i = n - d; i < n; i++) id[v[i]] = 0;       cout << ans << endl;     }   }   