#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll mod = 998244353;
const double eps = DBL_EPSILON;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k, d;
    cin >> n >> k >> d;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    set<int> s;
    map<int, int> m;
    for (int i = 0; i < d; i++) {
      s.insert(a[i]);
      m[a[i]]++;
    }
    int ans = s.size();
    for (int i = d; i < n; i++) {
      m[a[i - d]]--;
      if (m[a[i - d]] == 0) s.erase(a[i - d]);
      s.insert(a[i]);
      m[a[i]]++;
      ans = min(ans, (int)s.size());
    }
    cout << ans << "\n";
  }
  return 0;
}
