#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t, n, x;
  cin >> t;
  while (t--) {
    cin >> n >> x;
    int ans;
    if (n <= 2)
      cout << 1 << endl;
    else {
      ans = floor((n - 3) / x);
      cout << ans + 2 << endl;
    }
  }
  return 0;
}
