#include <bits/stdc++.h>
using namespace std;
int cal(vector<int> a, int x, int c) {
  int l = 0;
  int r = x - 1;
  int count = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (a[mid] <= c) {
      count = mid + 1;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return count;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k, d;
    cin >> n >> k >> d;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int c, cc;
    int r, l;
    map<int, int> m;
    int i;
    for (int i = 0; i < n - d + 1; i++) {
      if (i == 0) {
        for (int j = 0; j < d; j++) m[a[j]]++;
        c = m.size();
      } else {
        if (m[a[i - 1]] == 1)
          m.erase(a[i - 1]);
        else
          m[a[i - 1]]--;
        m[a[d + i - 1]]++;
        if (m.size() < c) c = m.size();
      }
    }
    cout << c << endl;
  }
}
