#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> ma;
  for (long long i = 0; i < d; i++) ma[a[i]]++;
  long long ans = ((long long)(ma).size());
  ma[a[d - 1]]--;
  if (ma[a[d - 1]] == 0) ma.erase(a[d - 1]);
  for (long long i = 0; i <= n - d; i++) {
    ma[a[i + d - 1]]++;
    ans = min(ans, ((long long)(ma).size()));
    ma[a[i]]--;
    if (ma[a[i]] == 0) ma.erase(a[i]);
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1;
  cin >> t;
  for (long long i = 0; i < t; i++) solve();
}
