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