#include <bits/stdc++.h>
using namespace std;
int a[1000], b[1000];
float z, x;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < t; i++) {
    if (a[i] < 3) {
      cout << '1' << endl;
    } else {
      z = a[i] - 2;
      x = ceil(z / b[i]) + 1;
      cout << x << endl;
    }
  }
  return 0;
}
