#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long p = 1e9 + 7;
const long long md = 1e9 + 7;
long long power(long long n, long long p) {
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = (res * n) % md;
    p /= 2;
    n = (n * n) % md;
  }
  return res;
}
void solve() {
  long long n, k, d;
  cin >> n >> k >> d;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  queue<long long> q;
  map<long long, long long> mp;
  long long i = 0;
  while (i < d) q.push(v[i]), mp[v[i]]++, i++;
  long long ans = mp.size();
  for (long long j = i; j < n; j++) {
    mp[v[j]]++;
    q.push(v[j]);
    long long k = q.front();
    q.pop();
    mp[k]--;
    if (mp[k] == 0) mp.erase(k);
    amin(ans, mp.size());
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
