#include <bits/stdc++.h>
using namespace std;
const long long int MAX = 9187201950435737471;
const long long int INF = 1e6;
const double pi = acos(-1);
const int N = 200500;
const long long mod = 1000000007;
const int M = 2147483647;
const int lg = 101;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    int n, k, d;
    cin >> n >> k >> d;
    int A[n + 1];
    for (int i = 1; i <= n; i++) cin >> A[i];
    map<int, int> mp;
    int cnt = 0, Ans = 0;
    for (int i = 1; i <= d; i++) {
      if (mp[A[i]] == 0) {
        cnt++;
        Ans++;
      }
      mp[A[i]]++;
    }
    int Left = 2, Right = d + 1;
    while (Right <= n) {
      mp[A[Left - 1]]--;
      if (mp[A[Left - 1]] == 0) cnt--;
      mp[A[Right]]++;
      if (mp[A[Right]] == 1) cnt++;
      Ans = min(Ans, cnt);
      Left++;
      Right++;
    }
    cout << Ans << endl;
  }
  return 0;
}
