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