#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int f = 0; f < t; f++) {
    int n, k, d;
    cin >> n >> k >> d;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> ls(k + 1, -1);
    int l = 0, r = 0;
    int ans = 1000000000 + 7, cr = 0;
    for (int i = 0; i < d; i++) {
      if (ls[a[i]] < l) cr++;
      ls[a[i]] = i;
      r = i;
    }
    ans = min(ans, cr);
    while (r + 1 < n) {
      if (ls[a[l]] == l) cr--;
      l++;
      if (ls[a[r + 1]] < l) cr++;
      ls[a[r + 1]] = r + 1;
      r++;
      ans = min(ans, cr);
    }
    cout << ans << '\n';
  }
}
