#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  cin >> t;
  for (long long w = 0; w < t; w++) {
    long long n, k, d;
    cin >> n >> k >> d;
    map<long long, long long> q;
    vector<long long> a(n);
    for (long long& i : a) cin >> i;
    long long sum = 0;
    for (long long i = 0; i < d; i++) {
      if (q[a[i]] == 0) {
        sum++;
      }
      q[a[i]]++;
    }
    long long ans = sum;
    for (long long l = 0, r = d; r < n; l++, r++) {
      q[a[l]]--;
      if (q[a[l]] == 0) {
        sum--;
      }
      if (q[a[r]] == 0) {
        sum++;
      }
      q[a[r]]++;
      ans = min(ans, sum);
    }
    cout << ans << endl;
  }
}
