#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  int n, x;
  while (t--) {
    cin >> n >> x;
    if (n == 1 || n == 2)
      cout << 1 << endl;
    else {
      if ((n - 2) % x == 0)
        cout << (n - 2) / x + 1 << endl;
      else
        cout << (n - 2) / x + 2 << endl;
    }
  }
}
