#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tt;
  cin >> tt;
  while (tt--) {
    long long n, x;
    cin >> n >> x;
    if (n == 1 || n == 2) {
      cout << 1 << '\n';
      continue;
    }
    long long ans;
    if ((n - 2) % x == 0)
      ans = (n - 2) / x;
    else
      ans = (n - 2) / x + 1;
    cout << ans + 1 << '\n';
  }
}
