#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k, d;
    cin >> n >> k >> d;
    long long a[n];
    for (int i = 0, ggdem = n; i < ggdem; ++i) cin >> a[i];
    map<long long, long long> m;
    for (int i = 0, ggdem = d; i < ggdem; ++i) {
      m[a[i]]++;
    }
    long long res = ((long long)m.size());
    for (int i = d, ggdem = n; i < ggdem; ++i) {
      m[a[i - d]]--;
      if (m[a[i - d]] == 0) m.erase(a[i - d]);
      m[a[i]]++;
      res = min(res, ((long long)m.size()));
    }
    cout << res << "\n";
  }
  return 0;
}
