#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x, ans;
    cin >> n >> x;
    if (n <= 2) {
      cout << 1 << endl;
      continue;
    }
    ans = (n - 2) / x;
    if ((2 + x * ans) < n) ans++;
    cout << ans + 1 << endl;
  }
}
