#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, x;
  cin >> t;
  while (t--) {
    cin >> n >> x;
    if (n <= 2) {
      cout << 1 << "\n";
      continue;
    }
    int ans = 1, l = 3, r = 2 + x;
    while (n < l || n > r) {
      ans++;
      l = r + 1;
      r = l + x - 1;
    }
    cout << ans + 1 << "\n";
  }
  return 0;
}
