#include <bits/stdc++.h>
using namespace std;
long long po(long long a, long long b) {
  if (b == 0) return 1;
  long long ans = 1;
  if (b % 2 == 0) {
    ans = po(a, b / 2) % 1000000007;
    ans = (ans % 1000000007 * ans % 1000000007) % 1000000007;
  } else {
    ans = po(a, (b - 1) / 2) % 1000000007;
    ans = (ans % 1000000007 * ans % 1000000007 * a) % 1000000007;
  }
  return ans % 1000000007;
}
vector<string> tokens;
void separate_string(string line) {
  stringstream check1(line);
  string lav;
  while (getline(check1, lav, '*')) {
    tokens.push_back(lav);
  }
}
vector<long long> divisors;
void get_Divisors(long long n) {
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        divisors.push_back(n / i);
      } else {
        divisors.push_back(i);
        divisors.push_back(n / i);
      }
    }
  }
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
void solve() {
  long long n, x;
  cin >> n >> x;
  if (n <= 2) {
    cout << "1";
    return;
  }
  n = n - 2;
  long long ans = n / x;
  if (n % x != 0) ans++;
  cout << ans + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
}
