#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int q = 0; q < t; q++) {
    int n, k, d;
    int arr[100000] = {0};
    int qwe[100000] = {0};
    cin >> n >> k >> d;
    int ans = 0;
    for (int r = 1; r <= n; r++) {
      cin >> arr[r];
    }
    for (int w = 1; w <= d; w++) {
      qwe[arr[w]]++;
      if (qwe[arr[w]] == 1) ans++;
    }
    int j = 1;
    int p = ans;
    for (int i = d + 1; i <= n; i++) {
      qwe[arr[j]]--;
      if (qwe[arr[j]] == 0) p--;
      qwe[arr[i]]++;
      if (qwe[arr[i]] == 1) p++;
      j++;
      if (p < ans) ans = p;
    }
    cout << ans << endl;
  }
  return 0;
}
