#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    int l = 1;
    int r = 2;
    int i = 0;
    for (i = 1; i < 1000; i++) {
      if (l <= n && r >= n) break;
      int k = r;
      l = k + 1;
      r = k + x;
    }
    cout << i << endl;
  }
  return 0;
}
