#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, x;
  cin >> n >> x;
  int ans = 1;
  if (n == 1 || n == 2)
    cout << 1 << endl;
  else {
    int j = 2;
    while (1) {
      for (int i = 1; i <= x; i++) j++;
      ans++;
      if (j >= n) break;
    }
    cout << ans << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
