#include <bits/stdc++.h>
using namespace std;
int64_t inf = 1000 * 1000 * 1000;
int64_t inf64 = inf * inf;
int64_t mod = 1e9 + 7;
int64_t nll = 0;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr << fixed << setprecision(8);
  srand(time(0));
  auto START_TIME = chrono::high_resolution_clock::now();
  double ttime = clock();
  int32_t t;
  cin >> t;
  while (t-- > 0) {
    int64_t n, k, d;
    cin >> n >> k >> d;
    vector<int64_t> a(n);
    vector<int64_t> gist(k + 3, 0);
    for (int32_t i = 0; i < n; ++i) cin >> a[i];
    int32_t l = 0;
    int64_t ans = inf;
    int64_t cnt = 0;
    for (int32_t i = 0; i < n; ++i) {
      ++gist[a[i]];
      if (gist[a[i]] == 1) ++cnt;
      if (i - l + 1 > d) {
        --gist[a[l]];
        if (gist[a[l]] == 0) --cnt;
        ++l;
      }
      if (i - l + 1 == d) ans = min(ans, cnt);
    }
    cout << ans << endl;
    ;
  }
  cerr << endl
       << chrono::duration<long double>(chrono::high_resolution_clock::now() -
                                        START_TIME)
              .count()
       << " sec.";
}
