#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, c, t, j, x;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld", &n);
    scanf("%lld", &x);
    if (n <= 2)
      cout << "1\n";
    else {
      cout << ceil((float)(n - 2) / x) + 1 << endl;
    }
  }
  return 0;
}
