#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, d;
    cin >> n >> k >> d;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    map<int, int> p;
    long long int l = 0, size = 0, m = 99999999;
    for (int i = 0; i < n; i++) {
      if (i < d) {
        if (p[a[i]] == 0) {
          size++;
        }
        p[a[i]]++;
        if (i == d - 1) {
          m = min(m, size);
        }
      } else {
        if (p[a[l]] == 1) {
          size--;
        }
        p[a[l]]--;
        l++;
        if (p[a[i]] == 0) {
          size++;
        }
        p[a[i]]++;
        m = min(m, size);
      }
    }
    cout << m << endl;
  }
  return 0;
}
