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