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