#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &res) {
  char c;
  T flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
  res *= flag;
}
void wenjian() {
  freopen("concatenation.in", "r", stdin);
  freopen("concatenation.out", "w", stdout);
}
void tempwj() {
  freopen("hash.in", "r", stdin);
  freopen("hash.out", "w", stdout);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long qpow(long long a, long long b, long long mod) {
  a %= mod;
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
struct chongzai {
  int c;
  bool operator<(const chongzai &b) const { return c > b.c; }
} sss;
const int maxn = 1e6 + 177;
const int maxm = 1e6 + 177;
const long long mod = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, x;
    scanf("%d%d", &n, &x);
    if (n == 1 || n == 2) {
      printf("1\n");
      continue;
    }
    for (int i = 2;; i++) {
      int now = i - 1;
      int sum = now * x + 2;
      if (sum >= n) {
        printf("%d\n", i);
        break;
      }
    }
  }
}
