#include <bits/stdc++.h>
using namespace std;
void sieve(long long int p[], long long int n) {
  for (long long int i = 3; i <= n; i += 2) {
    p[i] = 1;
  }
  for (long long int i = 3; i <= n; i++) {
    if (p[i] == 1) {
      for (long long int j = i * i; j <= n; j += i) {
        p[j] = 0;
      }
    }
  }
  p[2] = 1;
  p[0] = p[1] = 0;
}
long long int recpow(long long int x, long long int n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return recpow((x * x) % 1000000007, n / 2);
  else
    return (x * recpow((x * x) % 1000000007, (n - 1) / 2)) % 1000000007;
}
int32_t main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k, d;
    cin >> n >> k >> d;
    long long int a[n];
    for (long long int i = 0; i < n; i++) cin >> a[i];
    map<long long int, long long int> m;
    long long int i = 0, count = 0;
    for (long long int i = 0; i < d; i++) {
      count += (++m[a[i]] == 1);
    }
    long long int ans = count;
    for (long long int i = d; i < n; i++) {
      m[a[i - d]]--;
      if (m[a[i - d]] == 0) {
        m.erase(a[i - d]);
      }
      m[a[i]]++;
      ans = min(ans, (long long int)m.size());
    }
    cout << ans << "\n";
  }
}
