#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double PI = acos(-1.0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k, d;
    cin >> n >> k >> d;
    vector<int> ar(n);
    for (int i = 0; i < n; ++i) {
      cin >> ar[i];
    }
    int high = 0, low = 0;
    int cnt = 0;
    map<int, int> mp;
    while (high < d) {
      mp[ar[high]] += 1;
      if (mp[ar[high]] == 1) cnt += 1;
      high += 1;
    }
    int ans = cnt;
    while (high < n) {
      mp[ar[high]] += 1;
      if (mp[ar[high]] == 1) cnt += 1;
      mp[ar[low]] -= 1;
      if (mp[ar[low]] == 0) cnt -= 1;
      ans = min(ans, cnt);
      high += 1;
      low += 1;
    }
    cout << ans << endl;
  }
  return 0;
}
