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