#include <bits/stdc++.h>
using namespace std;
using vi = vector<long long>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using iii = pair<ii, ii>;
using vii = vector<ii>;
using viii = vector<pair<ii, ii>>;
using vvii = vector<vii>;
using vs = vector<string>;
using vd = vector<double>;
using vvd = vector<vd>;
using viid = vector<pair<ii, double>>;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    if (n < 3) {
      cout << 1 << '\n';
      continue;
    }
    n -= 2;
    cout << 1 + (n + x - 1) / x << '\n';
  }
}
