#include <bits/stdc++.h>
using namespace std;
int t, n, k, d, a[200010];
int num[1000010];
bool check(int mid) {
  int l = 1, r = 1, nl = 1, nr = 1, cnt = 1;
  num[a[1]]++;
  while (nr < n) {
    nr++;
    num[a[nr]]++;
    if (num[a[nr]] == 1) {
      cnt++;
    }
    while (cnt > mid) {
      num[a[nl]]--;
      if (num[a[nl]] == 0) {
        cnt--;
      }
      nl++;
    }
    if (r - l + 1 < nr - nl + 1) {
      l = nl, r = nr;
    }
  }
  for (register int i = nl; i <= nr; i++) {
    num[a[i]]--;
  }
  return r - l + 1 >= d;
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d%d", &n, &k, &d);
    for (register int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    int l = 1, r = n, mid, res;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (check(mid)) {
        res = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
