#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k, d;
  cin >> n >> k >> d;
  long long show[n];
  for (long long i = 0; i < n; ++i) {
    cin >> show[i];
  }
  map<long long, long long> make_pair;
  long long shows = INT_MAX;
  long long check = 0;
  for (long long i = 0; i < d; i++) {
    if (make_pair[show[i]] == 0) check++;
    make_pair[show[i]]++;
    shows = make_pair.size();
  }
  if (d < n) {
    for (long long i = d; i < n; i++) {
      if (make_pair[show[i]] == 0) check++;
      make_pair[show[i]]++;
      make_pair[show[i - d]]--;
      if (make_pair[show[i - d]] == 0) check--;
      shows = min(shows, check);
    }
  } else
    shows = check;
  cout << shows << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
