#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << endl;
  err(++it, args...);
}
const long long mod = 1e9 + 7;
const long long maxN = 2e5;
const long long INF = 1e18;
const long double EPS = 1e-9;
int t, n, k, d, rs, cnt;
int a[maxN];
map<int, int> m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    m.clear();
    cnt = 0;
    cin >> n >> k >> d;
    for (long long i = 0; i <= n - 1; i++) cin >> a[i];
    for (long long i = 0; i <= d - 1; i++)
      if (++m[a[i]] == 1) cnt++;
    rs = cnt;
    for (int l = 0, r = d; r < n; l++, r++) {
      if (--m[a[l]] == 0) cnt--;
      if (++m[a[r]] == 1) cnt++;
      rs = min(rs, cnt);
    }
    cout << rs << "\n";
  }
  return 0;
}
