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