#include <bits/stdc++.h>
using namespace std;
const int N = 200005, K = 1000005;
int a[N], vis[K];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, k, d;
    scanf("%d %d %d", &n, &k, &d);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      vis[a[i]] = 0;
    }
    int typ = 0;
    for (int i = 1; i <= d; i++) {
      if (!vis[a[i]]) typ++;
      vis[a[i]]++;
    }
    int Min = typ;
    for (int i = d + 1; i <= n; i++) {
      vis[a[i - d]]--;
      if (!vis[a[i - d]]) typ--;
      if (!vis[a[i]]) typ++;
      vis[a[i]]++;
      Min = min(Min, typ);
    }
    printf("%d\n", Min);
  }
  return 0;
}
