#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, x, n, a;
  cin >> T;
  while (T) {
    cin >> n >> x;
    if (n <= 2) {
      cout << 1 << endl;
    } else {
      a = ceil((double)(n - 2) / x);
      cout << a + 1 << endl;
    }
    T--;
  }
  return 0;
}
