#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, x;
    cin >> n >> x;
    if (n == 1 || n == 2)
      cout << 1 << endl;
    else {
      n -= 2;
      long long ans = (n + x - 1) / x;
      cout << ans + 1 << endl;
    }
  }
}
