#include <bits/stdc++.h>
using namespace std;
long long int poow(long long int a, long long int b) {
  long long int p = 1000000007;
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    if (n < 3) {
      cout << 1 << endl;
      continue;
    }
    n = n - 2;
    cout << ((n + x - 1) / x) + 1 << endl;
  }
  return 0;
}
