#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, d;
    cin >> n >> k >> d;
    int *arr = (int *)calloc(k + 1, sizeof(int));
    vector<int> a;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      a.push_back(x);
    }
    int num = 0;
    int min_num = 0;
    for (int i = 0; i < d; i++) {
      if (arr[a[i]] == 0) num++;
      arr[a[i]]++;
    }
    min_num = num;
    int i = d;
    while (i < n) {
      arr[a[i - d]]--;
      if (arr[a[i - d]] == 0) num--;
      if (arr[a[i]] == 0) num++;
      arr[a[i]]++;
      if (num < min_num) min_num = num;
      i++;
    }
    cout << min_num << endl;
    free(arr);
  }
  return 0;
}
