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