#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, d;
    cin >> n >> k >> d;
    int a[n];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      a[i]--;
    }
    int cnt[k];
    memset(cnt, 0, sizeof cnt);
    int cc = 0;
    for (int i = 0; i < d; ++i) {
      if (cnt[a[i]] == 0) {
        cc++;
      }
      cnt[a[i]]++;
    }
    int ans = cc;
    for (int i = 1; i <= n - d; ++i) {
      if (cnt[a[i - 1]] == 1) {
        cc--;
      }
      cnt[a[i - 1]]--;
      if (cnt[a[i + d - 1]] == 0) {
        ++cc;
      }
      cnt[a[i + d - 1]]++;
      ans = min(ans, cc);
    }
    cout << ans << endl;
  }
  return 0;
}
