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