#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int nax = 1e5 + 5;
const int MOD = 1e9 + 7;
using pii = pair<int, int>;
int main() {
  int t, n, x;
  cin >> t;
  while (t--) {
    cin >> n >> x;
    if (n <= 2)
      cout << 1 << endl;
    else {
      for (int i = 2; i <= n; i++) {
        int l = (i - 2) * x + 3;
        int r = (i - 1) * x + 2;
        if (n <= r && n >= l) {
          cout << i << endl;
          break;
        }
      }
    }
  }
  return 0;
}
