#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 << "\n";
    else {
      n = n - 2;
      int p = n / x;
      if (n % x == 0)
        cout << p + 1 << "\n";
      else
        cout << p + 2 << "\n";
    }
  }
}
