#include <bits/stdc++.h>
const int INFI = (1 << 29);
const long long INFL = (1LL << 62);
using namespace std;
long long f[1000010];
void solve() {
  long long n, k, d, c = 0, r = INFL;
  cin >> n >> k >> d;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  for (long long i = 0; i < n; i++) {
    f[v[i]]++;
    c += (f[v[i]] == 1);
    if (i >= d) {
      f[v[i - d]]--;
      c -= (!f[v[i - d]]);
    }
    if (i >= (d - 1)) r = min(r, c);
  }
  cout << r << "\n";
  for (long long i = 0; i < n; i++) f[v[i]] = 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long casos;
  cin >> casos;
  while (casos--) solve();
  return 0;
}
