#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, n;
  cin >> t;
  while (t--) {
    long long int n, x;
    cin >> n >> x;
    if (n == 1 || n == 2) {
      cout << 1 << endl;
      continue;
    } else {
      n -= 2;
      if (n % x == 0) {
        cout << n / x + 1 << endl;
      } else {
        cout << n / x + 2 << endl;
      }
    }
  }
  return 0;
}
