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