#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    if ((n - 2) <= 0)
      cout << 1 << "\n";
    else {
      n = n - 2;
      double p = (ceil)((n * 1.0) / x);
      cout << (int)p + 1 << "\n";
    }
  }
}
