#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
const int mod = 1e9 + 7;
const int _mod = 228228227;
const int prime = 997;
const int _prime = 29;
int n, k, d, a[N], u[N * 5];
inline void purify() { memset(u, 0, sizeof u); }
inline void precalc() {}
inline void read() {
  scanf("%d %d %d", &n, &k, &d);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
}
inline void solve() {
  int ans = 1e9, cnt = 0;
  for (int i = 1; i <= d; i++) {
    if (u[a[i]] == 0) {
      cnt++;
    }
    u[a[i]]++;
  }
  int l = 1, r = d;
  while (r <= n) {
    ans = min(ans, cnt);
    if (u[a[l]] == 1) cnt--;
    u[a[l]]--;
    l++, r++;
    if (u[a[r]] == 0) cnt++;
    u[a[r]]++;
  }
  printf("%d\n", ans);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    purify();
    read();
    solve();
  }
}
