#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k, d;
  int test;
  cin >> test;
  for (int tcase = 1; tcase <= test; tcase++) {
    cin >> n >> k >> d;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    set<int> S;
    multiset<int> MS;
    for (int i = 0; i < d; i++) {
      S.insert(v[i]);
      MS.insert(v[i]);
    }
    int mn = INT_MAX;
    for (int i = d - 1, j = 0; i < n;) {
      if (S.size() < mn) {
        mn = S.size();
      }
      auto it = MS.find(v[j]);
      MS.erase(it);
      if (MS.count(v[j]) == 0) {
        S.erase(v[j]);
      }
      i++;
      j++;
      if (i == n) {
        break;
      }
      S.insert(v[i]);
      MS.insert(v[i]);
    }
    cout << mn << "\n";
  }
  return 0;
}
