#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int INF = (int)1e18;
void fileio() {}
void solve() {
  long long n, k, d;
  cin >> n >> k >> d;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  map<long long, long long> mp;
  long long i = 0, j = 0, mn = INT_MAX;
  for (long long j = 0; j < n; j++) {
    mp[v[j]]++;
    if (j + 1 >= d) {
      mn = min(mn, (long long)mp.size());
      mp[v[i]]--;
      if (mp[v[i]] == 0) mp.erase(v[i]);
      i++;
    }
  }
  cout << mn << "\n";
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  fileio;
  int t;
  cin >> t;
  while (t--) solve();
}
