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