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