#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x, sum = 2, c = 1;
    cin >> n >> x;
    while (sum < n) {
      sum += x;
      c++;
    }
    cout << c << endl;
  }
  return 0;
}
