#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, r;
vector<int> a;
int main() {
  int q;
  cin >> q;
  while (q--) {
    scanf("%d %d", &n, &r);
    a.clear();
    a.reserve(n);
    for (int i = 1; i <= n; i++) {
      int first;
      scanf("%d", &first);
      a.push_back(first);
    }
    sort(a.begin(), a.end());
    a.resize(unique(a.begin(), a.end()) - a.begin());
    int tot = a.size();
    long long ans = tot;
    for (int i = 0; i < tot; i++) {
      int nxt = tot - 1 - i;
      ans = min(ans, nxt + (max(0LL, a[i] - nxt * 1LL * r) + r - 1) / r);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
