#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  vector<int> anss;
  for (int m = 0; m < t; m++) {
    int n, k, d;
    cin >> n >> k >> d;
    map<int, int> a;
    deque<int> tmp;
    int last_key;
    int ind = 0;
    for (int i = 0; i < d; i++) {
      int x;
      cin >> x;
      if (a[x] == 0) ind++;
      a[x]++;
      tmp.push_back(x);
    }
    last_key = tmp.front();
    int ans = ind;
    for (int i = d; i < n; i++) {
      a[last_key]--;
      if (a[last_key] == 0) ind--;
      tmp.pop_front();
      int x;
      last_key = tmp.front();
      cin >> x;
      if (a[x] == 0) ind++;
      a[x]++;
      tmp.push_back(x);
      ans = min(ans, ind);
    }
    anss.push_back(ans);
  }
  for (int i = 0; i < anss.size(); i++) {
    cout << anss[i] << endl;
  }
  cin.get();
  cin.get();
}
