#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 20;
const long long INF = LONG_MAX;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k, d;
    cin >> n >> k >> d;
    vector<long long> a(n);
    for (auto& i : a) cin >> i;
    map<long long, long long> cnt;
    long long ans = 1e9;
    for (long long i = 0; i < d; ++i) {
      cnt[a[i]]++;
    }
    ans = cnt.size();
    for (long long j = d; j < n; ++j) {
      cnt[a[j]]++;
      cnt[a[j - d]]--;
      if (cnt[a[j - d]] == 0) cnt.erase(a[j - d]);
      ans = min(ans, (long long)cnt.size());
    }
    cout << ans << endl;
  }
  return 0;
}
