#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> ans;
  int t, n, x;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n >> x;
    int tempAns;
    if (n <= 2)
      ans.push_back(1);
    else {
      n -= 2;
      if (n % x == 0)
        tempAns = n / x;
      else {
        tempAns = 1 + n / x;
      }
      ans.push_back(tempAns + 1);
    }
  }
  for (auto x : ans) cout << x << endl;
}
