#include <bits/stdc++.h>
using namespace std;
int arr[200000] = {0};
void solve() {
  int n, k, d;
  cin >> n >> k >> d;
  map<int, int> shows;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  int cnt = 0, ans = 1e9;
  for (int i = 0; i < d; ++i) {
    if (shows[arr[i]] == 0) {
      ++cnt;
    }
    ++shows[arr[i]];
  }
  ans = min(ans, cnt);
  for (int i = d; i < n; ++i) {
    --shows[arr[i - d]];
    if (shows[arr[i - d]] == 0) {
      --cnt;
    }
    if (shows[arr[i]] == 0) {
      ++cnt;
    }
    ++shows[arr[i]];
    ans = min(ans, cnt);
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t, test_case = 0;
  cin >> t;
  for (; test_case < t; ++test_case) {
    solve();
  }
  return 0;
}
