#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e4 + 10;
const long long INF = 1e9 + 7;
void solve() {
  long long n, k, d, ans = 1e9;
  cin >> n >> k >> d;
  vector<long long> a(n);
  deque<long long> q;
  map<long long, long long> cnt;
  set<long long> st;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < d; i++) {
    cnt[a[i]]++;
    q.push_back(a[i]);
    st.insert(a[i]);
  }
  ans = st.size();
  for (long long i = d; i < n; i++) {
    auto x = q.front();
    if (cnt[x] > 0) cnt[x]--;
    q.pop_front();
    if (cnt[x] == 0) st.erase(x);
    q.push_back(a[i]);
    st.insert(a[i]);
    cnt[a[i]]++;
    if (st.size() < ans) ans = st.size();
  }
  cout << ans << endl;
}
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
