#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxN = (int)log2(1e5);
void solve() {
  int n, x;
  cin >> n >> x;
  if (n < 3) {
    cout << 1 << endl;
    return;
  }
  cout << 1 + ceil((double)(n - 2) / x) << endl;
}
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  }
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
