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