#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
const long long LLINF = 1000000000000000007LL;
const double EPS = 1e-9;
const int sz = 200100;
int ar[sz];
map<int, int> m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (int i1 = 0; i1 < t; ++i1) {
    int k, n, d;
    cin >> n >> k >> d;
    for (int i = 0; i < n; ++i) {
      cin >> ar[i];
    }
    for (int i = 0; i < d; ++i) {
      m[ar[i]]++;
    }
    int mn = m.size();
    for (int i = 0; i < n - d; ++i) {
      m[ar[i]]--;
      if (!m[ar[i]]) m.erase(ar[i]);
      m[ar[i + d]]++;
      mn = min(mn, (int)m.size());
    }
    cout << mn << endl;
    m.clear();
  }
}
