#include <bits/stdc++.h>
using namespace std;
vector<int> prime_Numbers;
bool primes[1000005];
void prime(int n) {
  for (int i = 2; i <= n; i++) primes[i] = true;
  for (int i = 2; i <= n; i++) {
    if (primes[i] == true) {
      prime_Numbers.push_back(i);
      for (int j = i + i; j <= n; j += i) primes[j] = false;
    }
  }
}
int fib(int n) {
  if (n == 1 || n == 0) return n;
  return fib(n - 1) + fib(n - 2);
}
long long fastpower(int b, int p) {
  if (p == 0) return 1;
  long long term = fastpower(b, p / 2);
  term *= term;
  if (p % 2 != 0) return term *= b;
  return term;
}
long long arr[3005];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, d;
    cin >> n >> k >> d;
    int arr[n + 2];
    set<int> st;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    for (int i = 0; i < d; i++) {
      st.insert(arr[i]);
      mp[arr[i]]++;
    }
    int mnm = st.size();
    for (int i = d; i < n; i++) {
      mp[arr[i - d]]--;
      if (mp[arr[i - d]] == 0) st.erase(arr[i - d]);
      st.insert(arr[i]);
      mp[arr[i]]++;
      mnm = min(mnm, (int)st.size());
    }
    cout << min(mnm, (int)st.size()) << endl;
  }
  return 0;
}
