#include <bits/stdc++.h>
using namespace std;
const long long int ARR = 1e5;
const long long int INF = 1e9;
const long long int mod = 1e9 + 7;
void IO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  int n, x;
  cin >> n >> x;
  if (n == 1 || n == 2) {
    cout << "1\n";
    return;
  }
  cout << (n - 3) / x + 2 << "\n";
  return;
}
int main() {
  IO();
  long long int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
