#include <bits/stdc++.h>
int main() {
  using namespace std;
  int t1;
  cin >> t1;
  while (t1--) {
    int n;
    int x;
    cin >> n >> x;
    if (n == 1 || n == 2)
      cout << "1" << endl;
    else {
      int c = n - 2;
      if (c % x == 0)
        cout << c / x + 1 << endl;
      else {
        cout << c / x + 2 << endl;
      }
    }
  }
  return 0;
}
