#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long int n, x;
    cin >> n;
    cin >> x;
    int ch = 0;
    long int end = 2, flag = 2;
    if (n <= 2)
      cout << "1" << endl;
    else {
      while (ch != 1) {
        if ((end + 1) <= n && (x + end) >= n) {
          ch = 1;
        } else {
          flag++;
          end = x + end;
        }
      }
      cout << flag << endl;
    }
  }
}
