#include <bits/stdc++.h>
using namespace std;
int main() {
  double n, a, b, c;
  cin >> n;
  while (n >= 1) {
    n = n - 1;
    cin >> a >> b;
    if ((a == 1) || (a == 2)) {
      cout << 1 << endl;
    } else {
      if (double((a - 2) / b) == int((a - 2) / b)) {
        c = (a - 2) / b + 1;
      } else {
        c = int((a - 2) / b) + 2;
      }
      cout << c << endl;
    }
  }
  return 0;
}
