#include <bits/stdc++.h>
using namespace std;
long long n, k, d, a[200005];
int main(int argc, char const *argv[]) {
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> k >> d;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    long long ans = d, j = 0, uni = 0;
    multiset<long long> s;
    for (int i = 0; i <= n - d; ++i) {
      while (j < n && j - i < d) {
        if (s.find(a[j]) == s.end()) uni++;
        s.insert(a[j]);
        j++;
      }
      ans = min(ans, uni);
      s.erase(s.find(a[i]));
      if (s.find(a[i]) == s.end()) uni--;
    }
    cout << ans << '\n';
  }
  return 0;
}
