#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const long long nax = 0;
void solve() {
  map<long long, long long> make_pair;
  long long n, k, d;
  cin >> n >> k >> d;
  long long arr[n + 5];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  long long j = 0, mins = inf;
  for (int i = 0; i < n; ++i) {
    make_pair[arr[i]]++;
    if (i >= d) {
      make_pair[arr[j]]--;
      if (make_pair[arr[j]] == 0) {
        make_pair.erase(arr[j]);
      }
      mins = min(mins, (long long)make_pair.size());
      j++;
    } else {
      mins = make_pair.size();
    }
  }
  cout << mins << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
