#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, x, f;
  cin >> t;
  while (t--) {
    cin >> n >> x;
    if (n < 3) {
      cout << "1" << endl;
      continue;
    }
    f = 2;
    f += (n - 2) / x;
    if ((n - 2) % x == 0) f--;
    cout << f << endl;
  }
  return 0;
}
