#include <bits/stdc++.h>
using namespace std;
struct str {};
long long int gcd(long long int a, long long int b) {
  if (b == 0) return (a);
  return (gcd(b, a % b));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    int ans = 1;
    if (n == 1 || n == 2) {
      ans = 1;
    } else {
      n -= 2;
      ans += (n / x);
      if (n % x != 0) {
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
