#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, n, k, d, now, max;
  cin >> a;
  for (int i = 0; i < a; ++i) {
    cin >> n >> k >> d;
    now = 0;
    max = 0;
    vector<int> ser(k + 1, 0);
    vector<int> v(n);
    for (int j = 0; j < n; ++j) cin >> v[j];
    for (int u = 0; u < d; ++u) {
      if (ser[v[u]] == 0) now++;
      ser[v[u]]++;
    }
    max = now;
    for (int u = d; u < n; ++u) {
      if (ser[v[u - d]] == 1) {
        now--;
      }
      ser[v[u - d]]--;
      if (ser[v[u]] == 0) {
        now++;
      }
      ser[v[u]]++;
      if (now < max) max = now;
    }
    cout << max << '\n';
  }
}
