#include <bits/stdc++.h>
using namespace std;
int main() {
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    int n, k, d;
    int ans = INT_MAX;
    scanf("%d %d %d", &n, &k, &d);
    map<int, int> freq;
    int *arr = new int[n + 1]();
    for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
    for (int i = 1; i <= n; ++i) {
      if (i - d >= 1) {
        freq[arr[i - d]]--;
        if (!freq[arr[i - d]]) freq.erase(arr[i - d]);
      }
      freq[arr[i]]++;
      if (i >= d) ans = min(ans, (int)freq.size());
    }
    printf("%d\n", ans);
  }
  return 0;
}
