#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    if (n == 1 || n == 2)
      cout << "1" << endl;
    else {
      int y = floor((n - 3) / x) + 2;
      cout << y << endl;
    }
  }
  return 0;
}
