#include <bits/stdc++.h>
using namespace std;
void show() {
  int n, k, d;
  cin >> n >> k >> d;
  int col = 0;
  multiset<int> sp;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < d; ++i) {
    if (sp.find(a[i]) == sp.end()) {
      ++col;
    }
    sp.insert(a[i]);
  }
  int ans = 1e9;
  for (int i = d; i < n; ++i) {
    ans = min(ans, col);
    if (sp.find(a[i]) == sp.end()) {
      ++col;
    }
    sp.insert(a[i]);
    sp.erase(sp.find(a[i - d]));
    if (sp.find(a[i - d]) == sp.end()) {
      --col;
    }
  }
  cout << min(ans, col) << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    show();
  }
  return 0;
}
