#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const unsigned gen_seed =
    std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);
int main() {
  int t;
  cin >> t;
  int n, x;
  for (int aff = 0; aff < t; aff++) {
    cin >> n >> x;
    int l = 1;
    int cur = 2;
    while (cur < n) {
      cur += x;
      l += 1;
    }
    cout << l << endl;
  }
}
