#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k, d;
  cin >> n >> k >> d;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = d;
  unordered_map<int, int> umap;
  int leftIdx = 0;
  int rightIdx = 0;
  while (rightIdx < n) {
    int val = arr[rightIdx];
    if (rightIdx - leftIdx == d) {
      ans = min(ans, (int)umap.size());
      int removeVal = arr[leftIdx];
      if (umap[removeVal] == 1) {
        umap.erase(removeVal);
      } else {
        umap[removeVal]--;
      }
      leftIdx++;
    }
    if (umap.find(val) == umap.end()) {
      umap[val] = 1;
    } else {
      umap[val]++;
    }
    rightIdx++;
  }
  ans = min(ans, (int)umap.size());
  cout << ans << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t != 0) {
    solve();
    t--;
  }
  return 0;
}
