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