#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
const int maxn = 2e5 + 5;
int a[maxn];
void show() {
  map<int, int>::iterator it;
  for (it = mp.begin(); it != mp.end(); it++) {
    cout << (*it).first << "-" << (*it).second << "   ";
  }
  cout << endl;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    mp.clear();
    int n, k, d;
    scanf("%d%d%d", &n, &k, &d);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < d; i++) {
      mp[a[i]]++;
    }
    int mi = mp.size();
    for (int i = d; i < n; i++) {
      mp[a[i - d]]--;
      if (mp[a[i - d]] == 0) mp.erase(a[i - d]);
      mp[a[i]]++;
      int tt = mp.size();
      mi = min(mi, tt);
    }
    printf("%d\n", mi);
  }
}
