#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
pair<int, int> dx[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void solve() {
  int n, x;
  cin >> n >> x;
  int a = 2;
  int cnt = 1;
  while (a < n) {
    a += x;
    cnt++;
  }
  cout << cnt << "\n";
}
int main() {
  ios_base ::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  cin >> tt;
  while (tt--) {
    solve();
  }
  return 0;
}
