#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, d;
    cin >> n >> k >> d;
    vector<int> a(n);
    unordered_map<int, int> cnt;
    set<int> s;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (i < d) {
        cnt[a[i]]++;
        s.insert(a[i]);
      }
    }
    int i = d, j = 0;
    int m = (int)s.size();
    while (i < n) {
      cnt[a[j]]--;
      if (cnt[a[j]] <= 0) s.erase(a[j]);
      cnt[a[i]]++;
      s.insert(a[i]);
      m = min(m, (int)s.size());
      i++;
      j++;
    }
    cout << m << '\n';
  }
  return 0;
}
