#include <bits/stdc++.h>
using namespace std;
const int N = 2e6;
const int N2 = 3e5;
const int INF = 1e9;
int q;
int a[N2], cnt[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> q;
  for (int(it) = (1); (it) <= (q); (it) += (1)) {
    int n, k, d;
    cin >> n >> k >> d;
    for (int(i) = (1); (i) <= (n); (i) += (1)) {
      cin >> a[i];
      cnt[a[i]] = 0;
    }
    int l = 1, r = d, cur = 0;
    for (int(i) = (1); (i) <= (d); (i) += (1)) {
      if (!cnt[a[i]]) ++cur;
      ++cnt[a[i]];
    }
    int mn = INF;
    while (r <= n) {
      mn = min(mn, cur);
      --cnt[a[l]];
      if (cnt[a[l]] == 0) --cur;
      ++l;
      ++r;
      if (cnt[a[r]] == 0) ++cur;
      ++cnt[a[r]];
    }
    cout << mn << '\n';
  }
  return 0;
}
