#include <bits/stdc++.h>
using namespace std;
bool umin(unsigned long long &a, unsigned long long b) {
  return (b < a) ? (a = b, 1) : 0;
}
const int mxN = 300;
void solve() {
  int n, x;
  cin >> n >> x;
  if (n <= 2)
    cout << 1 << endl;
  else
    cout << (1 + (n - 2 + x - 1) / x) << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    solve();
  }
}
