#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int n, k, d;
  while (t--) {
    map<int, int> mp;
    vector<int> v;
    cin >> n >> k >> d;
    int a[n + 5], ans = 1000000, cnt = 0, x;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      v.push_back(a[i]);
    }
    for (int i = 0; i < n; i++) {
      cnt++;
      mp[v[i]]++;
      if (cnt >= d) {
        mp[v[cnt - d]]--;
        x = mp.size();
        ans = min(ans, x);
        if (mp[v[cnt - d]] == 0) {
          map<int, int>::iterator it = mp.find(v[cnt - d]);
          mp.erase(it);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
