#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    if (n == 1 or n == 2)
      cout << 1 << "\n";
    else {
      n -= 2;
      cout << (int)ceil((n * 1.0) / x) + 1 << "\n";
    }
  }
  return 0;
}
