#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long power(long long n, int k) {
  long long x = 1;
  int i;
  for (i = 0; i < k; i++) {
    x = x * n;
  }
  return x;
}
bool prime(long long x) {
  long long i;
  if (x == 1)
    return 0;
  else {
    for (i = 2; i * i <= x; i++) {
      if (x % i == 0) return false;
    }
    return true;
  }
}
long long count1(vector<long long>& a, long long n, long long x) {
  sort(a.begin(), a.end());
  long long st = 0, en = n - 1, mid, s1 = -1, s2 = -1, s3;
  while (st <= en) {
    mid = (st + en) / 2;
    if (a[mid] == x) {
      s1 = mid;
      en = mid - 1;
    } else if (a[mid] > x) {
      en = mid - 1;
    } else {
      st = mid + 1;
    }
  }
  st = 0;
  en = n - 1;
  while (st <= en) {
    mid = (st + en) / 2;
    if (a[mid] == x) {
      s2 = mid;
      st = mid + 1;
    } else if (a[mid] > x) {
      en = mid - 1;
    } else {
      st = mid + 1;
    }
  }
  if (s1 == -1 && (s2 == -1))
    return 0;
  else {
    long long c = s2 - s1 + 1;
    return c;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int Test;
  Test = 1;
  cin >> Test;
  while (Test--) {
    int num, x;
    cin >> num >> x;
    int ans = 1;
    if (num <= 2)
      cout << ans << endl;
    else {
      int xx = 2;
      while (xx < num) {
        xx = xx + x;
        ans++;
      }
      cout << ans << endl;
    }
  }
}
