#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k, d;
  cin >> n >> k >> d;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  map<long long, long long> mp;
  for (long long i = 0; i < d; i++) mp[a[i]]++;
  long long ans = mp.size();
  long long j = 0;
  for (long long i = d; i < n; i++) {
    mp[a[j]]--;
    if (mp[a[j]] == 0) mp.erase(a[j]);
    mp[a[i]]++;
    long long u = mp.size();
    ans = min(ans, u);
    j++;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
