#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, x;
  scanf("%d%d", &n, &x);
  if (n < 2) n = 2;
  int ans = ((n - 2) + x - 1) / x + 1;
  printf("%d\n", ans);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
