#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, x;
  cin >> n >> x;
  int floor = 1;
  int apt = 3;
  if (n == 1 || n == 2) {
    cout << 1 << "\n";
    return;
  }
  while (1) {
    if (apt <= n) {
      floor++;
      apt = apt + x;
    } else {
      break;
    }
  }
  cout << floor << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int q;
  cin >> q;
  while (q--) {
    solve();
  }
  return 0;
}
