#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  int x;
  cin >> n >> x;
  if (n == 1 or n == 2) {
    cout << 1 << endl;
    return;
  }
  long long cont = 1;
  n -= 2;
  while (n > x) {
    n -= x;
    cont++;
  }
  cont++;
  cout << cont << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t-- > 0) {
    solve();
  }
  return 0;
}
