#include <bits/stdc++.h>
using namespace std;
struct abc {
  long long int b, c;
};
bool compare(abc x1, abc x2) { return (x1.b < x2.b); }
void swap(long long int *a, long long int *b) {
  long long int temp = *a;
  *a = *b;
  *b = temp;
}
const long long int N = 2e5 + 3, A = 1e6 + 3;
long long int n, k, d, b[A], a[N], ans, c;
int32_t main() {
  long long int t;
  cin >> t;
  while (t--) {
    cin >> n >> k >> d;
    ans = n;
    c = 0;
    for (long long int i = 1; i <= n; i++) {
      cin >> a[i];
      if (!b[a[i]]) c++;
      b[a[i]]++;
      if (i > d) {
        b[a[i - d]]--;
        if (!b[a[i - d]]) c--;
      }
      if (i >= d) ans = c < ans ? c : ans;
    }
    for (long long int i = 1; i <= n; i++) b[a[i]] = 0;
    cout << ans << "\n";
  }
}
