#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int q, n, k, d;
int a[N];
vector<int> anses;
void solve() {
  map<int, int> ser;
  int unic = 0;
  for (int i = 0; i < d; ++i) {
    if ((ser[a[i]]++) == 0) ++unic;
  }
  int ans = unic;
  for (int i = d; i < n; ++i) {
    if ((--ser[a[i - d]]) == 0) --unic;
    if ((ser[a[i]]++) == 0) ++unic;
    ans = min(ans, unic);
  }
  anses.push_back(ans);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> q;
  while (q--) {
    cin >> n >> k >> d;
    for (int i = 0; i < n; ++i) cin >> a[i];
    solve();
  }
  for (auto ans : anses) cout << ans << endl;
}
