#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
void solve() {
  int n, x;
  cin >> n >> x;
  if (n <= 2) {
    cout << 1 << endl;
    return;
  }
  for (int i = 1; i < 1000; i++) {
    if (n <= i * x + 2) {
      cout << i + 1 << endl;
      return;
    }
  }
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < (int)(t); i++) solve();
}
