#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    double n, x;
    cin >> n >> x;
    if ((n == 1) || (n == 2)) {
      cout << 1 << '\n';
      continue;
    }
    double z = ceil((max(n - 2, (double)0)) / x) + 1;
    cout << z << '\n';
  }
  return 0;
}
