#include <bits/stdc++.h>
using namespace std;
int t, n, x;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> x;
    if (n <= 2)
      cout << 1;
    else {
      for (int floor = 2, num = 3;; floor++) {
        if (num + x > n) {
          cout << floor;
          break;
        } else {
          num += x;
        }
      }
    }
    cout << "\n";
  }
}
