#include <bits/stdc++.h>
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end() {}
int n, x;
inline void solve() {
  cin >> n >> x;
  int now = 1, sum = 2;
  while (sum < n) {
    sum += x;
    now++;
  }
  cout << now << '\n';
}
int main() {
  TIME__START = clock();
  int Test = 1;
  scanf("%d", &Test);
  while (Test--) {
    solve();
  }
  TIME__END = clock();
  program_end();
  return 0;
}
