#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) {
    int n, first;
    cin >> n >> first;
    int count = 1;
    int start = first + 2;
    while (1) {
      if (n <= 2) {
        cout << "1\n";
        break;
      }
      if ((start - (first - 1)) <= n && n <= start) {
        count += 1;
        cout << count << "\n";
        break;
      } else {
        start += first;
        count += 1;
      }
    }
  }
  return 0;
}
