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