#include <bits/stdc++.h>
using namespace std;
void Start() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); }
bool endline = false;
bool endlineA = false;
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& i : v) {
    in >> i;
  }
  return in;
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  for (auto i : v) {
    out << i;
    if (!endline) {
      out << ' ';
    } else {
      out << '\n';
    }
  }
  if (!endline && endlineA) {
    out << '\n';
  }
  return out;
}
template <class T, class U>
istream& operator>>(istream& in, pair<T, U>& p) {
  in >> p.first >> p.second;
  return in;
}
template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U>& p) {
  out << p.first << ' ' << p.second;
  return out;
}
long long gettime() {
  return chrono::high_resolution_clock::now().time_since_epoch().count() /
         1000000;
}
mt19937_64 getrand(
    chrono::high_resolution_clock::now().time_since_epoch().count());
long long randnum(long long l, long long r) {
  return l + getrand() % (r - l + 1);
}
signed main() {
  Start();
  long long q;
  cin >> q;
  while (q--) {
    long long n, k, d;
    cin >> n >> k >> d;
    vector<long long> a(n);
    cin >> a;
    map<long long, long long> cnt;
    for (long long i = 0; i < d - 1; i++) {
      cnt[a[i]]++;
    }
    long long mn = 1e9;
    for (long long i = d - 1; i < n; i++) {
      cnt[a[i]]++;
      if (i - d >= 0) {
        cnt[a[i - d]]--;
        if (cnt[a[i - d]] == 0) cnt.erase(a[i - d]);
      }
      mn = min(mn, (long long)cnt.size());
    }
    cout << mn << '\n';
  }
  return 0;
}
