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