Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is $n$. 

There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains $2$ apartments, every other floor contains $x$ apartments each. Apartments are numbered starting from one, from the first floor. I.e. apartments on the first floor have numbers $1$ and $2$, apartments on the second floor have numbers from $3$ to $(x + 2)$, apartments on the third floor have numbers from $(x + 3)$ to $(2 \cdot x + 2)$, and so on.

Your task is to find the number of floor on which Petya lives. Assume that the house is always high enough to fit at least $n$ apartments.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases. Then $t$ test cases follow.

The only line of the test case contains two integers $n$ and $x$ ($1 \le n, x \le 1000$) — the number of Petya's apartment and the number of apartments on each floor of the house except the first one (there are two apartments on the first floor).


-----Output-----

For each test case, print the answer: the number of floor on which Petya lives.


-----Example-----
Input
4
7 3
1 5
22 5
987 13

Output
3
1
5
77



-----Note-----

Consider the first test case of the example: the first floor contains apartments with numbers $1$ and $2$, the second one contains apartments with numbers $3$, $4$ and $5$, the third one contains apartments with numbers $6$, $7$ and $8$. Therefore, Petya lives on the third floor.

In the second test case of the example, Petya lives in the apartment $1$ which is on the first floor.

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Implementation


Solutions:
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	temp = (n - 2) % x
	if n in [1, 2]:
		print(1)
	elif temp == 0:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)


import math
t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	c = 2
	a = 1
	while c < n:
		c += x
		a += 1
	print(a)


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n == 1:
		print(n)
	else:
		print(math.ceil((n - 2) / x + 1))


from math import ceil
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		F = ceil((n - 2 + x) / x)
		print(F)


import sys
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *
for _ in range(ii1()):
	(n, x) = iia()
	if n <= 2:
		print(1)
	else:
		n -= 2
		ans = 1
		ans += ceil(n / x)
		print(ans)


import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a <= 2:
		print(1)
	else:
		a -= 2
		print(1 + math.ceil(a / b))


t = int(input())
for T in range(t):
	(n, x) = map(int, input().split())
	k = 1
	if n < 3:
		print(1)
	else:
		while n > x * k + 2:
			k += 1
		print(k + 1)


from math import ceil

def cal(n, k):
	if n == 1 or n == 2:
		return 1
	else:
		return ceil((n - 2) / k) + 1
for i in range(int(input())):
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	print(cal(a, b))


from math import ceil, floor
t = int(input())
ans = []
for i in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		ans.append(1)
	else:
		ans.append(floor((n - 3) / x) + 2)
for a in ans:
	print(a)


t = int(input())
while t:
	t -= 1
	(n, x) = list(map(int, input().split()))
	ans = 1
	total = 2
	if n <= 2:
		print(1)
		continue
	while True:
		total += x
		ans += 1
		if total >= n:
			print(ans)
			break


import math

def codeF(n, x):
	print(1 if n <= 2 else (n - 3) // x + 2)
t = int(input())
for i in range(0, t):
	(n, x) = [int(x) for x in input().split()]
	codeF(n, x)


import math
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	x -= 2
	if x <= 0:
		print(1)
	else:
		print(math.ceil(x / y) + 1)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	print(max((n - 3) // x + 2, 1))


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n > 2:
		print((n - 3) // x + 2)
	else:
		print(1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print(-(-(n - 2) // x) + 1)


t = int(input())
s = ''
for i in range(1, t + 1):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	if n < 3:
		s += '1\n'
	else:
		s += str((n - 3) // x + 2) + '\n'
print(s)


import math
tc = int(input())
for _ in range(tc):
	[n, x] = list(map(int, input().split()))
	if n < 3:
		print(1)
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print(math.ceil((n - 2) / x) + 1)


T = int(input())
for i in range(T):
	(n, x) = map(int, input().split(' '))
	if n == 1 or n == 2:
		print(1)
	else:
		n = n - 2
		if n % x == 0:
			ans = n // x + 1
			print(ans)
		else:
			ans = n // x + 2
			print(ans)


s = int(input())
for i in range(s):
	(n, r) = map(int, input().split())
	if n <= 2:
		print('1')
	else:
		n = n - 2
		bl = 1
		g = 2
		while bl == 1:
			if n <= r:
				print(g)
				bl = 0
			else:
				n = n - r
				bl = 1
				g = g + 1


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	for i in range(1000):
		if n == 1 or n == 2:
			print(1)
			break
		elif i * x <= n <= (i + 1) * x + 2:
			print(i + 2)
			break


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		t = 0
		if n % x:
			t = 1
		print(n // x + t + 1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, x) = LI()
		if n < 3:
			rr.append(1)
		else:
			rr.append((n - 2 + x - 1) // x + 1)
	return JA(rr, '\n')
print(main())


from math import ceil
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n = n - 2
		ans = ceil(n / x) + 1
		print(ans)


def floornum():
	t = int(input())
	for i in range(t):
		(n, x) = [int(x) for x in input().split()]
		if n < 3:
			print('1', end='\n')
		else:
			n -= 2
			z = int(n / x) + 1
			if n % x != 0:
				z += 1
			print(z, end='\n')
floornum()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	(f, a) = (1, 2)
	while n > a:
		a += x
		f += 1
	print(f)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		z = 0
	elif n == 3 or n < x:
		z = 1
	else:
		p = n - 2
		z = p % x
		if z == 0:
			z = p // x
		else:
			z = p // x + 1
	print(z + 1)


def ab(n, k):
	if n == 1 or n == 2:
		return 1
	n -= 2
	x = n // k
	y = n % k
	if y == 0:
		return x + 1
	else:
		return x + 2
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(ab(n, k))


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	(N, x) = map(int, readline().split())
	if N <= 2:
		Ans[qu] = 1
		continue
	Ans[qu] = 2 + (N - 3) // x
print('\n'.join(map(str, Ans)))


from bisect import *
from collections import *
from math import *
from heapq import *
from typing import List
from itertools import *
from operator import *
from functools import *
import sys
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n < 3:
		ans = 1
	else:
		ans = ceil((n - 2) / x) + 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
		continue
	n -= 2
	print((n + x - 1) // x + 1)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, x) = value()
	if n <= 2:
		print(1)
	else:
		n -= 2
		print(1 + Ceil(n, x))


from math import ceil

def d(n, x):
	if 1 <= n <= 2:
		return 1
	else:
		n = n - 2
		n = ceil(n / x)
		return n + 1
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	print(d(n, x))


import math as m
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print(m.ceil((n - 2) / x) + 1)


def solve(n, x):
	cur = 2
	res = 1
	while cur < n:
		cur += x
		res += 1
	print(res)
t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	solve(n, x)


t = int(input())
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	for j in range(n):
		if n == 1 or n == 2:
			print(1)
			break
		elif n >= j * x + 3 and n <= (j + 1) * x + 2:
			print(j + 2)
			break


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		cnt = 1
		k = 3
		while k <= n and x <= k + x - 1:
			cnt += 1
			k += x
		print(cnt)


for s in range(int(input())):
	(n, x) = map(int, input().split())
	print((-((2 - n - x) // x), 1)[n + x == 2])


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	c = 2
	i = 1
	if n <= 2:
		print(1)
	else:
		while c <= n:
			if c == n:
				break
			c += x
			i += 1
		print(i)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	cnt = 2
	flats = 2 + x
	while n > flats:
		cnt += 1
		flats += x
	print(cnt)


import math
t = int(input())
p = 1
while p <= t:
	(n, x) = input().split(' ')
	n = int(n)
	x = int(x)
	a = math.ceil((n - 2) / x)
	a = int(a) + 1
	if n == 1:
		print('1')
	else:
		print(a)
	p = p + 1


t = int(input())
for i in range(t):
	(c, x) = map(int, input().split(' '))
	l = c - 2
	if l <= 0:
		print(1)
	elif l % x != 0:
		print(l // x + 2)
	else:
		print(l // x + 1)


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	if a[0] == 1 or a[0] == 2:
		print(1)
	else:
		print((a[0] - 3) // a[1] + +2)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		div = int(n / k)
		if n % k == 0:
			floor = div + 1
		else:
			floor = div + 2
		print(floor)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	floor = 1
	i = n - 2
	while i > 0:
		i -= x
		floor += 1
	print(floor)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	n = l[0]
	x = l[1]
	su = 2
	ct = 1
	if n == 1 or n == 2:
		print(1)
	else:
		su = 2
		while n > su:
			su = su + x
			ct += 1
		print(ct)


import math
t = int(input())
i = 0
while i < t:
	a = input().split(' ')
	n = int(a[0])
	x = int(a[1])
	floors = 1
	if n > 2:
		n = (n - 2) / x
		floors = math.ceil(n) + 1
	print(floors)
	i += 1


import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(n, x) = Read.list_int()
	if n <= 2:
		print(1)
		return
	r = math.ceil((n - 2) / x)
	print(r + 1)
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	if n == 1 or n == 2:
		print(1)
	else:
		count = (n - 2) // x
		rem = (n - 2) % x
		if rem > 0:
			count += 1
		print(count + 1)


testcase = int(input())
for i in range(testcase):
	(n, k) = list(map(int, input().split()))
	count = 1
	if n == 1:
		print(1)
	else:
		for i in range(2, n, k):
			count += 1
		print(count)


t = int(input())
for i in range(0, t):
	a = [int(i) for i in input().split()]
	if a[0] > 2:
		n = a[0] - 2
		x = a[1]
		m = n % x
		d = n // x
		if m == 0:
			print(d + 1)
		else:
			print(d + 2)
	else:
		print(1)


N = int(input())
for i in range(N):
	A = input().split()
	if int(A[0]) == 1 or int(A[0]) == 2:
		print(1)
	else:
		print(-((-int(A[0]) + 2) // int(A[1])) + 1)


test_cases = int(input())
for test_case in range(test_cases):
	pieces = input().split(' ')
	desr_apt = int(pieces[0])
	apt_per_floor = int(pieces[1])
	total_floors = 1
	current_apt = 1
	while current_apt < desr_apt:
		current_apt += 1
		if total_floors == 1:
			if current_apt == 3:
				total_floors += 1
		elif current_apt == (total_floors - 1) * apt_per_floor + 3:
			total_floors += 1
	print(total_floors)


t = int(input())
for i in range(t):
	(x, n) = map(int, input().split())
	res = 1
	if x > 2:
		x -= 2
		res = x // n + 1
		if x % n != 0:
			res += 1
	print(res)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	n -= 2
	ans = 1
	while n > 0:
		n -= x
		ans += 1
	print(ans)
	t -= 1


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	for i in range(ii()):
		(n, x) = mi()
		if n <= 2:
			print(1)
			continue
		n -= 2
		if n % x == 0:
			print(n // x + 1)
		else:
			print(n // x + 2)
main()


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, X):
	if N <= 2:
		return 1
	return 1 + (N - 2 + X - 1) // X
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N, X) = [int(x) for x in input().split()]
	ans = solve(N, X)
	print(ans)


def solve(n, x):
	if n <= 2:
		return 1
	floor = 1 + (n + x - 3) // x
	return floor
for case in range(int(input())):
	(a, b) = map(int, input().split())
	ans = solve(a, b)
	print(ans)


n = int(input())
f = [[int(z) for z in input().split()] for q in range(n)]
for (i, j) in f:
	if i < 3:
		print(1)
		continue
	else:
		print((i - 3) // j + 2)


from sys import stdin
from math import ceil
inp = lambda : stdin.readline().strip()
inpl = lambda : map(int, stdin.readline().strip().split())

def solve():
	(n, x) = inpl()
	if n <= 2:
		print(1)
	else:
		print(int(ceil((n - 2) / x) + 1))
for _ in range(int(inp()) if True else 1):
	solve()


import math

def main():
	n = int(input())
	answers = []
	for i in range(0, n):
		(n, x) = input().split()
		n = int(n)
		x = int(x)
		if n < 2:
			answers.append(1)
		else:
			answers.append(math.ceil((n - 2) / x) + 1)
	for answer in answers:
		print(answer)
main()


for i in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	a = n - 2
	if a < 0:
		print(1)
	elif a == 0:
		print(1)
	elif a % x != 0:
		print(int(a / x) + 2)
	else:
		print(int(a / x) + 1)


def solve(n, x):
	if n > 2:
		n -= 2
		return (n - 1) // x + 2
	return 1
testcases = int(input())
for i in range(testcases):
	(n, x) = map(int, input().split())
	print(solve(n, x))


t = int(input())
cases = []
for i in range(t):
	vals = input().split()
	cases.append((int(vals[0]), int(vals[1])))
for case in cases:
	n = case[0]
	x = case[1]
	if n <= 2:
		print(1)
	else:
		import math
		print(math.ceil((n - 2) / x) + 1)


import math
t = int(input())
ans = []
for i in range(t):
	(n, x) = map(int, input().split())
	n = n - 2
	if n < 0:
		ans.append(1)
	else:
		p = math.ceil(n / x)
		ans.append(p + 1)
for k in ans:
	print(k)


from math import ceil
for I in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n = n - 2
		print(ceil(n / x) + 1)


def main(n, x):
	if n == 1 or n == 2:
		return 1
	a = 3
	b = x + 2
	f = 1
	while True:
		if n >= a and n <= b:
			return f + 1
		f += 1
		a += x
		b += x
n = int(input())
for i in range(n):
	(n, x) = list(map(int, input().split(' ')))
	x = main(n, x)
	print(x)


t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		n = n - 2
		if n % x == 0:
			print(n // x + 1)
		else:
			print(n // x + 2)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
pisos = [[1, 2]]
departamentos = []

def generarSiguientePiso(n):
	global departamentos
	global pisos
	if len(pisos) == 1:
		for i in range(0, n):
			departamentos.append(pisos[0][1] + i + 1)
	else:
		for i in range(0, n):
			departamentos.append(pisos[len(pisos) - 1][n - 1] + i + 1)
	pisos.append(departamentos)
	departamentos = []
numeroCasos = inp()
inputs = []
for i in range(0, numeroCasos):
	entrada = list(map(int, input().split(' ')))
	inputs.append(entrada)

def calcularNumeroPiso(apartamento, apartxpiso):
	global pisos
	encontrado = False
	while not encontrado:
		for piso in pisos:
			if apartamento in piso:
				encontrado = True
				print(pisos.index(piso) + 1)
		generarSiguientePiso(apartxpiso)
	pisos = [[1, 2]]
for element in inputs:
	calcularNumeroPiso(element[0], element[1])


import math

def solve(n, x):
	if n == 1:
		return 1
	return math.ceil((n - 2) / x) + 1
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	print(solve(n, x))


import math

def floor_count(n, k):
	if n <= 2:
		return 1
	else:
		return math.ceil((n - 2) / k) + 1
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print(floor_count(n, k))


t = int(input())
while t > 0:
	t -= 1
	kara = input()
	lt = list(kara.strip().split())
	n = int(lt[0])
	x = int(lt[1])
	if n <= 2:
		print('1')
	else:
		ans = (n - 2 + x - 1) / x
		fin = int(ans)
		fin += 1
		print(fin)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	d = {1: 1, 2: 3}
	for i in range(2, n + 1):
		d[i + 1] = d[i] + x
	for i in d:
		if d[i] > n:
			print(i - 1)
			break


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	(n, x) = mInt()
	if n == 1 or n == 2:
		print(1)
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)


loop = int(input())
while loop > 0:
	loop -= 1
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n = n - 2
		div = n // x
		mod = n % x
		if mod == 0:
			print(div + 1)
		else:
			print(div + 2)


import math
t = int(input())
ans_list = []
for i in range(t):
	(n, x) = map(int, input().split())
	if n in range(1, 3):
		ans_list.append(1)
	else:
		ans_list.append(math.ceil((n - 2) / x) + 1)
for j in ans_list:
	print(j)


from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def main():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		if n <= 2:
			print(1)
		else:
			n -= 2
			print(int(math.ceil(n / x) + 1))
sync_with_stdio(False)
main()


gi = lambda : list(map(int, input().split()))
for _ in range(gi()[0]):
	(n, x) = gi()
	if n <= 2:
		print(1)
		continue
	n -= 2
	ans = 1 + n // x
	if n % x:
		ans += 1
	print(ans)


import math
from sys import stdin
for _ in range(int(stdin.readline())):
	(n, x) = map(int, stdin.readline().strip().split())
	if n == 1:
		print(1)
	else:
		a = n - 2
		z = int(math.ceil(a / x))
		print(z + 1)


t = int(input())
for i in range(t):
	nx = tuple(map(int, input().split()))
	ans = 1
	i = 2
	while i < nx[0]:
		ans += 1
		i += nx[1]
	print(ans)


N = int(input())
for i in range(N):
	str = input().split()
	n = int(str[0])
	x = int(str[1])
	if n <= 2:
		print(1)
	else:
		print(int((n - 3) / x) + 2)


import math
t = int(input())
while t > 0:
	t -= 1
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	n -= 2
	ans = 1 + math.ceil(n / x)
	if n <= 0:
		ans = 1
	print(ans)


def apartment():
	n = int(input())
	for i in range(n):
		listt = input().split(' ')
		(a, b) = (int(listt[0]), int(listt[1]))
		if a <= 2:
			print(1)
		else:
			a -= 2
			if a % b == 0:
				print(a // b + 1)
			else:
				print(a // b + 2)
apartment()


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print(1)
	else:
		n = n - 2
		ans = n // x
		if n % x != 0:
			ans += 1
		print(ans + 1)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	(n, x) = stdarr()
	if n <= 2:
		print(1)
	else:
		d = n - 2
		ap = d / x
		print(ceil(ap) + 1)


t = int(input())
while t:
	t += -1
	(n, x) = map(int, input().split())
	k = (n - 2) // x + bool((n - 2) % x)
	print(max(k + 1, 1))


from math import *
for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print(1)
	else:
		print(1 + (n - 2 + x - 1) // x)


import math
for _ in range(int(input())):
	(N, each) = [int(x) for x in input().split()]
	if N <= 2:
		print(1)
	else:
		print(math.ceil((N - 2) / each) + 1)


n1 = int(input())
for j in range(n1):
	(n, x) = map(int, input().split())
	temp = 2
	floor = 1
	while n > temp:
		if n == 1 or n == 2:
			print(floor)
			break
		floor += 1
		temp = temp + x
	print(floor)


import math
for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1:
		print(1)
		continue
	f = math.ceil((n - 2) / x) + 1
	print(f)


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	print((n + 2 * x - 3) // x if (n + 2 * x - 3) // x > 0 else 1)


for _ in range(int(input())):
	(N, X) = map(int, input().split())
	count = 1
	for i in range(3, N + 1, X):
		count += 1
	print(count)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
T = inp()
for case_no in range(T):
	(n, x) = invr()
	if n <= 2:
		print(1)
	else:
		print(2 + (n - 3) // x)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = (n - 3) // x
	if n == 1 or n == 2:
		print(1)
	else:
		print(a + 2)


t = int(input())
for _ in range(t):
	N = input()
	n = int(N.split()[0])
	x = int(N.split()[1])
	if n == 1 or n == 2:
		print('1')
	else:
		count = 1
		n = n - 2
		while n > 0:
			n = n - x
			count += 1
		print(count)


def floornum(x, y):
	if x <= 2:
		return 1
	if x > 2:
		if (x - 2) % y != 0:
			z = (x - 2) // y + 1 + 1
			return z
		elif (x - 2) % y == 0:
			z = (x - 2) // y + 1
			return z
testnum = int(input())
k = 0
testlist = []
anslist = []
while k < testnum:
	testlist.append(list(map(int, input().split())))
	a = testlist[k]
	anslist.append(floornum(a[0], a[1]))
	k += 1
p = 0
while p < testnum:
	print(anslist[p])
	p += 1


def check(n, x):
	if n < 3:
		return 1
	i = 2
	while 1:
		if n < (i - 1) * x + 3:
			return i
		i += 1
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	print(check(n, x))


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	f = 1
	tf = 0
	p = 2
	if n == 1 or n == 2:
		print(1)
	else:
		i = 0
		while True:
			tf = i * x + 2
			i = i + 1
			if n <= tf:
				print(i)
				break
	t = t - 1


T = int(input())
res = list()
for _ in range(T):
	(a, b) = tuple(map(int, input().split()))
	if a == 1 or a == 2:
		res.append(1)
		continue
	i = 3
	sum = 0
	while sum < a - 2:
		sum += b
		i += 1
	res.append(i - 2)
for i in res:
	print(i)


import math
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	count = 0
	if n <= 2:
		print(1)
		continue
	n = n - 2
	count += 1
	ans = math.ceil(n / x) + 1
	print(ans)


import math
t = int(input())
for _ in range(0, t):
	(n, x) = list(map(int, input().split()))
	if n == 1 or n == 2:
		print(1)
		continue
	else:
		q = (n - 2) / x
		print(math.ceil(q) + 1)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a
from collections import defaultdict

def solve():
	(n, x) = sep()
	if n == 1 or n == 2:
		print(1)
	else:
		print(1 + ceil((n - 2) / x))
testcase(int(inp()))


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = 2
	j = 1
	flag = 1
	if n == 1 or n == 2:
		print(1)
	else:
		while flag:
			f = l + 1
			l = j * x + 2
			if n >= f and n <= l:
				print(j + 1)
				flag = 0
				break
			else:
				j += 1


for t in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if a == 1:
		print('1')
	elif (a - 2) % b == 0:
		print((a - 2) // b + 1)
	else:
		print((a - 2) // b + 2)


for s in [*open(0)][1:]:
	(n, x) = map(int, s.split())
	n -= 2
	a = 1
	while n > 0:
		a += 1
		n -= x
	print(a)


def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print(ceil(n - 2, k) + 1)


t = int(input())
i = 0
nbr_inf = 0
while i < t:
	a = True
	i += 1
	(n, x) = map(int, input().split())
	nbr_floor = 1
	if n <= 2:
		print(nbr_floor)
		a = False
	while a == True:
		nbr_floor += 1
		nbr_inf = (nbr_floor - 2) * x + 3
		nbr_sup = (nbr_floor - 1) * x + 2
		if n >= nbr_inf and n <= nbr_sup:
			print(nbr_floor)
			a = False


from math import ceil
for tt in range(int(input())):
	(Pttya, NoAppa) = map(int, input().split())
	if Pttya in [1, 2]:
		print(1)
	else:
		Pttya -= 2
		print(ceil(Pttya / NoAppa + 1))


def ceil(n, x):
	return (x + n - 1) // x
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n - 2 <= 0:
		print(1)
	else:
		res = ceil(n - 2, x) + 1
		print(res)


import sys
infile = sys.stdin
next(infile)
for line in infile:
	l = list(map(int, line.split()))
	n = l[0]
	x = l[1]
	n2 = n - 2
	if n2 <= 0:
		print(1)
	elif n2 % x == 0:
		print(n2 // x + 1)
	else:
		print(n2 // x + 2)


import math
t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().strip().split(' ')]
	if n > 2:
		print(int(math.ceil((n - 2) / x)) + 1)
	else:
		print(1)


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = inar()
		i = 1
		take = 0
		while True:
			if i == 1:
				take += 2
			else:
				take += x
			if take >= n:
				print(i)
				break
			i += 1
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split(' '))
	floor = 1
	counts = 0
	if n < 3:
		print(floor)
	else:
		for i in range(3, n):
			counts += 1
			if counts % x == 0:
				floor += 1
		print(floor + 1)


import math
t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	if a == 1 or a == 2:
		print(1)
		continue
	else:
		a -= 2
		ans = 1 + math.ceil(a / b)
		print(ans)


def solve():
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		ans = 1 + n // x + (1 if n % x else 0)
		print(ans)
	return

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


t = int(input())
for i in range(t):
	k = 1
	(n, x) = map(int, input().split())
	s = 2
	while s < n:
		s = s + x
		k = k + 1
	if s >= n:
		print(k)


def solve(n, x):
	if n <= 2:
		return 1
	temp = n - 2
	floor_quo = temp // x + 1
	if temp % x == 0:
		return floor_quo
	return floor_quo + 1
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print(solve(n, x))


from os import remove
t = int(input())
for i in range(t):
	l = [int(i) for i in input().split()]
	if l[0] > 2:
		removed_ap = l[0] - 2
		y = removed_ap // l[1] + 1
		if removed_ap % l[1] == 0:
			print(y)
		else:
			print(y + 1)
	else:
		print(1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print([1, (n + x - 3) // x + 1][n - 2 > 0])


for s in [*open(0)][1:]:
	(n, x) = map(int, s.split())
	if n <= 2:
		print(1)
		continue
	for i in range(1000):
		if i * x + 3 <= n <= (i + 1) * x + 2:
			print(i + 2)


import math as m
t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	print((max(a - 2, 0) + b - 1) // b + 1)


t = int(input())
for y in range(t):
	inp = []
	inp = list(map(int, input().split()))
	n = inp[0]
	x = inp[1]
	if n == 1 or n == 2:
		print(1)
	elif (n - 2) % x != 0:
		print((n - 2) // x + 2)
	else:
		print((n - 2) // x + 1)


t = int(input())
nx = [map(int, input().split()) for _ in range(t)]
(n, x) = [list(i) for i in zip(*nx)]

def floornumber(n, x):
	if n <= 2:
		return 1
	else:
		n = n - 2
		(a, mod) = divmod(n, x)
		if mod != 0:
			return a + 2
		else:
			return a + 1
for i in range(t):
	ans = floornumber(n[i], x[i])
	print(ans)


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 10
	A = 10
	n = random.randint(1, N)
	a = [random.randint(1, A) for i in range(n)]
	return (n, a)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print((a1, a2), inp)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
ans = 0
for i in range(I()):
	ns = 0
	(n, x) = LI()
	if n <= 2:
		ans = 1
	else:
		ans = 1 + (n - 2 + x - 1) // x
	print(ans)


a = int(input())
for item in range(a):
	(b, c) = input().split()
	(b, c) = (int(b), int(c))
	if b <= 2:
		print(1)
	elif (b - 2) % c != 0:
		print((b - 2) // c + 2)
	elif (b - 2) % c == 0:
		print((b - 2) // c + 1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		print((n - 3) // x + 2)


for j in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	elif (n + (x - 2)) % x != 0:
		print((n + (x - 2)) // x + 1)
	else:
		print((n + (x - 2)) // x)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print('1')
	else:
		f = n - 2
		if f % x == 0:
			print(f // x + 1)
		else:
			print(f // x + 2)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	if n == 1 or n == 2:
		print(1)
	elif x == 1:
		print(n - 1)
	else:
		total = 2
		count = 1
		while n > total:
			total += x
			count += 1
		print(count)


T = int(input())
for t in range(T):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		k = (n - 2) % x
		if k == 0:
			print((n - 2) // x + 1)
		else:
			print((n - 2) // x + 2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		for i in range(1000):
			if n in range(i * x + 3, (i + 1) * x + 3):
				print(i + 2)
				break


def main():
	caseNum = int(input())
	for _ in range(caseNum):
		(n, x) = list(map(int, input().split(' ')))
		if n <= 2:
			print(1)
		elif (n + x - 2) % x == 0:
			print(int((n + x - 2) // x))
		else:
			print(int((n + x - 2) // x) + 1)
main()


import sys
from math import ceil
inp = sys.stdin.read().strip().split('\n')[1:]
out = []
for i in inp:
	(n, x) = map(int, i.split())
	out.append(int(ceil((n - 2) / x + 1)) or 1)
print(*out, sep='\n')


q = int(input())
for i in range(q):
	(b, a) = map(int, input().split())
	if b == 1 or b == 2:
		print(1)
	else:
		b = b - 3 + a
		c = b // a + 1
		print(c)


import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	print(math.ceil((n - 2) / x) + 1)


import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
input = sys.stdin.readline
getS = lambda : input().strip()
getN = lambda : int(input())
getList = lambda : list(map(int, input().split()))
getZList = lambda : [int(x) - 1 for x in input().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)

def solve():
	(n, m) = getList()
	if n <= 2:
		print(1)
		return
	else:
		f = (n - 3) // m
		print(f + 2)

def main():
	n = getN()
	for _ in range(n):
		solve()
	return
main()


def floor(n, x):
	if n <= 2:
		return 1
	ans = 1
	count = 2
	while count:
		if n >= count - x and n <= count:
			return ans
		count += x
		ans += 1
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	y = floor(n, x)
	print(y)


import sys
from copy import *
from bisect import *
from itertools import permutations as prm, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	(n, k) = mi()
	c = i = 0
	while c < n:
		if c == 0:
			c += 2
		else:
			c += k
		i += 1
		if c >= n:
			print(i)
			break


t = int(input())
while t:
	(n, x) = map(int, input().split())
	n = n - 2
	f = n // x
	f = f + 1
	if n % x != 0:
		f = f + 1
	if n + 2 < 3:
		f = 1
	print(f)
	t = t - 1


for _ in range(int(input())):
	(n, x) = list(map(int, input().strip().split()))
	if n == 1 or n == 2:
		print(1)
	else:
		c = 0
		n = n - 2
		while n > 0:
			c += 1
			n -= x
		print(c + 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ans = 0
	if (n - 2) % x != 0 and n > 2:
		ans = (n - 2) // x + 2
	elif n <= 2:
		ans = 1
	else:
		ans = (n - 2) // x + 1
	print(ans)


from math import ceil
t = int(input())
for _ in range(0, t):
	(n, x) = map(int, input().split())
	if n <= 2:
		ans = 1
	n = n - 2
	if n % x == 0 and n > 0:
		ans = 1 + int(n / x)
	elif n % x != 0 and n > 0:
		ans = 2 + int(n / x)
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print('1')
	elif n == 3:
		print(2)
	else:
		j = (n - 2) / x
		k = (n - 2) // x
		if j == k:
			print(k + 1)
		else:
			print(k + 2)


import sys

def countfloors(app, x):
	cur = 2
	floor = 1
	if app <= 2:
		print(1)
		return
	while app > cur:
		cur = cur + x
		floor += 1
	print(floor)
	return
num = int(input())
inp = []
for i in range(num):
	line = input()
	inp.append(line.split(' '))
for i in range(num):
	app = int(inp[i][0])
	x = int(inp[i][1])
	countfloors(app, x)


import math
query = int(input())
while query > 0:
	(p, n) = map(int, input().split(' '))
	if p <= 2:
		print(1)
	else:
		print(math.ceil((p - 2) / n) + 1)
	query -= 1


import math
t = int(input())
arr = []
for i in range(t):
	arr.append(list(map(int, input().split(' '))))
for i in range(len(arr)):
	n = arr[i][0]
	x = arr[i][1]
	ans = 0
	val = n - 2
	if val <= 0:
		ans = 1
	else:
		ans = 1 + math.ceil(val / x)
	print(ans)


import math
t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	if n == 1 or n == 2:
		print(1)
	else:
		f = int(math.ceil((n - 2) / x))
		print(f + 1)


import math
a = int(input())
q = 0
while a > 0:
	(n, x) = map(int, input().split())
	c = 0
	if n == 1 or n == 2:
		print(1)
	elif n > 2:
		n = n - 2
		c += 1
		q = n / x
		print(math.ceil(q) + c)
	a = a - 1


import math

def solve(N: int, X: int):
	floor = 1
	range1 = (floor - 1) * X + 3
	range2 = floor * X + 2
	while not range1 <= N <= range2:
		floor += 1
		range1 = (floor - 1) * X + 3
		range2 = floor * X + 2
	return floor + 1
for _ in range(int(input())):
	(N, X) = map(int, input().split())
	if N <= 2:
		print(1)
	else:
		print(solve(N, X))


t = int(input())
while t > 0:
	t -= 1
	(n, x) = [int(x) for x in input().split()]
	arr = [2]
	i = 0
	while True:
		arr.append(arr[i] + x)
		i += 1
		if n <= 2:
			print(1)
			break
		if n > arr[i - 1] and n <= arr[i]:
			print(i + 1)
			break


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().strip().split()))
	a = 1
	b = 2
	i = 0
	if n <= 2:
		print('1')
	else:
		print((n - 3) // x + 2)


from math import ceil
t = int(input())
nn = []
xx = []
for _ in range(t):
	(n, x) = map(int, input().split(' '))
	nn.append(n)
	xx.append(x)
for (n, x) in zip(nn, xx):
	print(1 if n <= 2 else ceil((n - 2) / x) + 1)


def R():
	return map(int, input().split())

def I():
	return int(input())
for _ in range(I()):
	(n, x) = R()
	print(1 + (n > 2) + max(0, n - 3) // x)


for _ in range(int(input())):
	(z, r) = map(int, input().split())
	z = z - 2
	l = 1
	while z > 0:
		l += 1
		z -= r
	print(l)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	floor = 1
	if n == 1 or n == 2:
		print(floor)
	else:
		floor = 2
		while True:
			limit = (floor - 1) * x + 2
			if limit >= n:
				print(floor)
				break
			else:
				floor += 1


testcase = int(input())
for t in range(testcase):
	(n, x) = [int(i) for i in input().split()]
	if n < 3:
		print(1)
	else:
		floor = -(-(n - 2) // x) + 1
		print(floor)


for _ in range(int(input())):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	lives = 0
	floor = 1
	if n > 2:
		a = n - 2
		lives = round(a / x)
		k = a / x
		if k > lives:
			lives = lives + 1
		print(floor + lives)
	else:
		print(floor)


t = int(input())
for i in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	if n <= 2:
		print(1)
		continue
	(p, i) = (2, 1)
	while n > p:
		p += k
		i += 1
	print(i)


import math
n = []
x = []
test = 0
choice = -1
l = []
while True:
	try:
		if choice == -1:
			test = int(input())
			choice += 1
		elif choice >= 0:
			l = list(input().split(' '))
			n.append(int(l[0]))
			x.append(int(l[1]))
			choice += 1
		if choice == test:
			break
	except EOFError:
		break
for i in range(0, test):
	level = 1
	if n[i] == 1 or n[1] == 2:
		print(1)
	else:
		level += math.ceil((n[i] - 2) / x[i])
		print(level)


import math
t = int(input())
while t > 0:
	t = t - 1
	l = input().split()
	n = int(l[0])
	x = int(l[1])
	f = 1
	n -= 2
	while n > 0:
		n -= x
		f += 1
	print(f)


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	if a <= 2:
		print(1)
		continue
	print(1 + (a - 2 + b - 1) // b)


import math
T = int(input())
while T:
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		print(math.ceil(n / x) + 1)
	T -= 1


t = int(input())
et = 1
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		while n > 0:
			n -= x
			et += 1
		print(et)
	et = 1


import math

def resolve(n, x):
	if n <= 2:
		return 1
	n -= 2
	return math.ceil(n / x) + 1
num_test = int(input())
for i in range(num_test):
	(n, x) = [int(x) for x in input().split()]
	print(resolve(n, x))


class Program:

	def __init__(self):
		self.testCases = int(input())

	def start(self):
		for i in range(self.testCases):
			case = input()
			case = case.split(' ')
			n = int(case[0])
			x = int(case[1])
			print(getFloor(n, x))

def getFloor(apartment, apartmentsEachFloor):
	floorApartmentsMax = 2
	coefficient = 1
	while floorApartmentsMax < apartment:
		floorApartmentsMax = coefficient * apartmentsEachFloor + 2
		coefficient += 1
	return coefficient
Program().start()


def solve():
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		i = 2
		apartment = 2
		while True:
			apartment += x
			if n <= apartment:
				print(i)
				break
			i += 1
T = int(input())
for _ in range(T):
	solve()


def ans(n, x):
	if n == 1 or n == 2:
		return 1
	return int(2 + (n - 3) / x)
m = int(input())
for j in range(m):
	arr = input().split()
	n = int(arr[0])
	x = int(arr[1])
	print(ans(n, x))


def flo(n, x):
	if n <= 2:
		return 1
	else:
		nd = 1
		n = n - 2
		nd += n // x
		if n % x == 0:
			return nd
		return nd + 1
for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	print(flo(n, x))


import math

def fun(arr, n, k):
	pass
try:
	t = int(input())
	for i in range(t):
		(aprtno, aptperfloor) = list(map(int, input().split()))
		if aprtno == 1 or aprtno == 2:
			print(1)
			continue
		else:
			aprtno -= 2
			floor = 1 + math.ceil(aprtno / aptperfloor)
			print(floor)
except:
	pass


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ans = 0
	if max(n - 2, 0) % x == 0:
		ans = max(n - 2, 0) // x + 1
	else:
		ans = max(n - 2, 0) // x + 2
	print(str(ans) + '\n')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		(res, remain) = divmod(n - 3, x)
		print(res + 2)


test_cases = int(input())
for i in range(test_cases):
	(petya, no_of_houses) = map(int, input().split())
	floor = (petya - 2) // no_of_houses
	remaining = (petya - 2) % no_of_houses
	if petya <= 2:
		print('1')
	elif remaining != 0:
		print(floor + 2)
	else:
		print(floor + 1)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a <= 2:
		print(1)
	elif (a - 2) % b == 0:
		print((a - 2) // b + 1)
	else:
		print((a - 2) // b + 2)


import math

def f(n, x):
	if n == 1 or n == 2:
		return 1
	else:
		return math.ceil((n - 2) / x) + 1
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	print(f(n, x))


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		p = math.ceil((n - 2) / k)
		print(1 + p)


import sys
from collections import defaultdict as dc
import math
from bisect import bisect, bisect_left, bisect_right
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	p = 2
	if n <= p:
		print(1)
	else:
		c = 1
		while p <= n:
			p += x
			c += 1
			if p >= n:
				print(c)
				break


for case in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	if n <= 2:
		print(1)
		continue
	c = 3
	a = 1
	while c + x - 1 < n:
		a += 1
		c += x
	print(a + 1)


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print('1')
	elif n > 2:
		k = math.ceil((n - 2) / x + 1)
		print(k)


import math
numLines = int(input(''))
for i in range(0, numLines):
	n_x = input('')
	n_x = n_x.split(' ')
	n = int(n_x[0])
	x = int(n_x[1])
	n = n - 2
	floor = 0
	if n <= 0:
		print('1')
	else:
		floor = floor + 1
		floor = floor + math.ceil(n / x)
		print(floor)


t = int(input())
for i in range(t):
	(n, x) = tuple(map(int, input().split()))
	if n < 3:
		print(1)
	elif (n - 2) % x != 0:
		print((n - 2) // x + 2)
	else:
		print((n - 2) // x + 1)


from math import ceil

def define_floor(flat, at_floor):
	if flat > 2:
		flat -= 2
	else:
		return 1
	return ceil(flat / at_floor + 1)
T = int(input())
for _ in range(T):
	(flat, flats_per_floor) = [int(x) for x in input().split()]
	print(define_floor(flat, flats_per_floor))


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	(n, x) = read_ints()
	if n <= 2:
		print(1)
	else:
		n -= 2
		print((n - 1) // x + 2)


import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)

def put():
	return map(int, stdin.readline().split())
for _ in range(int(input())):
	(n, x) = put()
	if n <= 2:
		print(1)
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)


def floor_num(a_num, a_floor):
	if a_num <= 2:
		return 1
	count = 1
	i = 2
	while a_num:
		i += a_floor
		count += 1
		if i >= a_num:
			break
	return count
test_cases = int(input())
for t in range(test_cases):
	(a_num, a_floor) = map(int, input().split())
	print(floor_num(a_num, a_floor))


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
for _ in range(int(input())):
	(n, x) = ilele()
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		floor = 1
		while n > 0:
			n -= x
			floor += 1
		print(floor)


t_case = int(input())
for i in range(t_case):
	n_x = str(input())
	(n, x) = (int(n_x.split(' ')[0]), int(n_x.split(' ')[1]))
	if n <= 2:
		print(1)
	else:
		a = (n - 2) / x
		if a == int(a):
			print(int(a + 1))
		else:
			print(int(a) + 2)


t = int(input())
for i in range(t):
	(n, k) = input().split(' ')
	n = int(n) - 2
	k = int(k)
	if n < 1:
		print(1)
	else:
		x = 0
		q = n // k
		r = n % k
		if r != 0:
			x = 1
		print(q + 1 + x)


a = int(input())
b = []
for i in range(a):
	(n, x) = map(int, input().split())
	if n <= 2:
		b.append(1)
	else:
		n = n - 2
		c = 2
		while n / x > 1:
			n -= x
			c += 1
		b.append(c)
for i in b:
	print(i)


t = int(input())
for y in range(t):
	(n, x) = map(int, input().split())
	floor = 2
	a = 3
	b = x + 2
	while True:
		if n in range(1, 3):
			print(1)
			break
		if n in range(a, b + 1):
			print(floor)
			break
		else:
			a += x
			b += x
			floor += 1


x1 = int(input())
for i in range(x1):
	(n, x) = map(int, input().split())
	c = 2
	d = 1
	while True:
		if n <= c:
			break
		else:
			c += x
			d += 1
	print(d)


import math
test = int(input())
for _ in range(test):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		apartment = math.ceil((n - 2) / x) + 1
		print(apartment)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		f = n // x
		if n % x:
			f += 1
		print(f + 1)


from math import ceil, floor
t = int(input())
for t0 in range(t):
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print(1)
	else:
		print(floor((n - 3) / x) + 2)


from math import ceil
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print(ceil(max(n - 2, 0) / x) + 1)


import math as m
x = int(input())
for z in range(x):
	(n, k) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		print(m.ceil((n - 2) / k) + 1)


def solve():
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		return
	from math import ceil
	print(ceil((n - 2) / x) + 1)
for _ in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	start = 1
	floor = 1
	i = 0
	while start <= n:
		if n == 1 or n == 2:
			print(1)
			break
		end = i * x + 2
		j = (i - 1) * x
		if end == 2:
			start = 1
		else:
			start = j + 3
			floor = floor + 1
		i = i + 1
		if n <= end and n >= start:
			print(floor)
			break
		else:
			continue


def cmp(key):
	return key[0]
t = int(input())
naswer = 0
for i in range(t):
	(n, x) = [int(i) for i in input().split()]
	if n <= 2:
		print(1)
	else:
		naswer = (n - 3) // x
		print(naswer + 2)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt

def solve():
	(n, x) = read()
	ans = (n - 2 + x - 1) // x
	print(max(ans + 1, 1))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


import math
n = int(input())
for i in range(n):
	f = [int(x) for x in input().split(' ')]
	if f[0] < 3:
		print(1)
	else:
		print(math.ceil((f[0] - 2) / f[1]) + 1)


for s in [*open(0)][1:]:
	(a, b) = map(int, s.split())
	print((a - 3 + b) // b + 1 if a > 2 else 1)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		print(int(math.ceil((n - 2) / k)) + 1)


import sys
tests = int(sys.stdin.readline())
output = []
while tests > 0:
	line = sys.stdin.readline()
	line = line.split(' ')
	flatNumb = int(line[0])
	everyFloor = int(line[1])
	flatNumb -= 2
	hisFloor = 1
	while flatNumb > 0:
		flatNumb -= everyFloor
		hisFloor += 1
	output.append(hisFloor)
	tests -= 1
print(*output, sep='\n')


from collections import defaultdict, Counter
import copy, math
from copy import deepcopy
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	j = n - 2
	if j <= 0:
		print(1)
	else:
		print(math.ceil(j / x) + 1)


t = int(input())
v = 1
lis = list()
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		lis.append(v)
	else:
		for j in range(3, n + 1, x):
			v += 1
		lis.append(v)
		v = 1
for i in lis:
	print(i)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print('1')
	else:
		r = n - 2
		if r % x == 0:
			floor = r // x
		else:
			floor = r // x + 1
		print(floor + 1)


import math as m
testcases = int(input())
cases = []
officialcases = []
for x in range(testcases):
	cases.append(input())
for x in cases:
	officialcases.append(x.split())
for x in officialcases:
	if int(x[0]) <= 2:
		print('1')
	else:
		result = m.ceil((int(x[0]) - 2) / int(x[1])) + 1
		print(str(result))


def apart(n, x):
	i = 0
	while 1:
		t = (n - i - 3 + 2 * x) / x
		i = i + 1
		if t.is_integer():
			return t
k = int(input())
for i in range(k):
	str = input()
	list1 = str.split(' ')
	n = int(list1[0])
	x = int(list1[1])
	if n == 1 or n == 2:
		print(1)
	else:
		print(int(apart(n, x)))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	c = 1
	n = n - 2
	while n > 0:
		c += 1
		n = n - x
	print(c)


import sys
t = int(input())
for tc in range(t):
	(n, x) = map(int, input().split())
	print(max(int((n + x - 3) / x) + 1, 1))


from math import *
from collections import *
from itertools import *
from functools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	n -= 2
	if n <= 0:
		print(1)
	else:
		x = ceil(n / k)
		print(x + 1)


def floor(n, x):
	if n == 1 or n == 2:
		return 1
	elif (n - 2) % x == 0:
		return (n - 2) // x + 1
	elif (n - 2) % x != 0:
		return (n - 2) // x + 2
for i in range(int(input())):
	(n, x) = map(int, input().split())
	print(floor(n, x))


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, x) = list(map(int, stdin.readline().split()))
	if n <= 2:
		print(1)
		continue
	ans = 0
	for fr in range(1000):
		if 3 + fr * x <= n <= 2 + (fr + 1) * x:
			ans = fr + 2
			break
	print(ans)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
from collections import deque, Counter, OrderedDict, defaultdict
from itertools import permutations, combinations
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split())

def msi():
	return map(str, input().strip().split())

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
from collections import deque, Counter, OrderedDict, defaultdict
from math import *
from itertools import permutations, combinations
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
vow = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def expo(x, y, m):
	if y == 0:
		return 1
	elif y % 2 == 0:
		return expo(x * x % m, y / 2, m)
	else:
		return x * expo(x * x % m, (y - 1) / 2, m) % m

def gcd(a, b):
	if a == 0:
		return (b, 0, 1)
	(gc, x1, y1) = gcd(b % a, a)
	x = y1 - b // a * x1
	y = x1
	return (gc, x, y)

def sieve(n):
	arr = [True] * (n + 1)
	arr[0] = False
	arr[1] = False
	for i in range(4, n + 1, 2):
		arr[i] = False
	for i in range(3, int(sqrt(n)) + 1, 2):
		if arr[i] == True:
			for j in range(i * i, n + 1, i):
				arr[j] = False
	return arr

def modInverse(x, y):
	(gc, x1, y1) = gcd(x, y)
	return (y1 + y) % y

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		(n, k) = mi()
		if n <= 2:
			print(1)
		else:
			print(ceil(n - 2, k) + 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def find_floor(n, x):
	if n == 1 or n == 2:
		return 1
	else:
		current_apt = 2
		current_floor = 2
		while current_apt + x < n:
			current_apt += x
			current_floor += 1
		return current_floor

def main():
	t = int(input())
	for i in range(t):
		temp = input()
		my_list = str(temp).rstrip('\n').split(' ')
		n = int(my_list[0])
		x = int(my_list[1])
		print(find_floor(n, x))
main()


def floor(t, x):
	if t == 1 or t == 2:
		return 1
	start = 2
	floor = 1
	while t > start:
		floor += 1
		start += x
	return floor
test = int(input())
for i in range(test):
	(t, x) = map(int, input().split())
	print(floor(t, x))


import math
for _ in range(int(input())):
	(net, one) = map(int, input().split())
	net -= 2
	if net > 0:
		print(math.ceil(net / one) + 1)
	else:
		print(1)


def solve():
	(n, x) = map(int, input().split())
	if n <= 2:
		return 1
	if n <= x:
		return 2
	steps = 0
	curr = 2
	while curr < n:
		steps += 1
		curr += x
	return steps + 1
t = int(input())
for _ in range(t):
	ans = solve()
	print(ans)


i = int(input())
for i in range(i):
	line = input().split()
	n = int(line[0])
	x = int(line[1])
	if n == 1 or n == 2:
		print(1)
	else:
		print(int((n - 3) / x + 2))


for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		for i in range(2, 1001):
			s = (i - 2) * x + 3
			e = (i - 1) * x + 2
			if s <= n <= e:
				print(i)
				break


def main(n, x):
	if n <= 2:
		return 1
	current_floor = 1
	last_apartment_number = 2
	while True:
		last_apartment_number += x
		current_floor += 1
		if last_apartment_number >= n:
			return current_floor
tt = int(input())
for _ in range(tt):
	(n, x) = map(int, input().split(' '))
	print(main(n, x))


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, x) = list(map(int, stdin.readline().rstrip().split()))
	ans = 2
	if n == 1 or n == 2:
		print(1)
		continue
	for i in range(1, 10001):
		if ans + i * x >= n:
			print(i + 1)
			break


from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + '\n')
from math import ceil
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		ans = ceil(n / x) + 1
		print(ans)


import sys
input = sys.stdin.readline

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math, itertools

def solve():
	(N, X) = getInts()
	if N <= 2:
		return 1
	N -= 3
	return N // X + 2
for _ in range(getInt()):
	print(solve())


for z in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		s = 2
		i = 2
		while True:
			if n <= s + x:
				print(i)
				break
			else:
				s += x
				i += 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	k = 0
	while True:
		if n == 1 or n == 2:
			print(1)
			break
		elif k * x + 3 <= n <= (k + 1) * x + 2:
			print(k + 2)
			break
		else:
			k += 1


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		(n, x) = Mint()
		if n == 1 or n == 2:
			print('1')
		else:
			n = n - 2
			print(ceil(n / x) + 1)
solution()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n in (1, 2):
		print(1)
	else:
		print(2 + (n - 3) // k)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		p = 2
		for j in range(2, n):
			p += x
			if n <= p:
				print(j)
				break


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 2:
		print(1)
	else:
		(a, b) = divmod(n - 2, x)
		if b == 0:
			print(a + 1)
		else:
			print(a + 2)


t = int(input())

def calc(n, x):
	f = 1
	if n == 1 or n == 2:
		return 1
	while True:
		if n in range((f - 1) * x + 3, f * x + 2 + 1):
			return f + 1
		f += 1
for i in range(t):
	(n, x) = map(int, input().split())
	print(calc(n, x))


import sys

def main():
	(n, x) = list(map(int, sys.stdin.readline().split()))
	if n < 3:
		print(1)
		return 0
	print((n - 2 + x - 1) // x + 1)
for i in range(int(sys.stdin.readline().strip())):
	main()


n = int(input())
for i in range(n):
	q = list(map(int, input().split()))
	count = 2
	x = q[1]
	a = q[0]
	mn = 3
	mx = x + 2
	if a <= 2:
		print(1)
	else:
		while not mn <= a <= mx:
			mn += x
			mx += x
			count += 1
		print(count)


t = int(input())
output = []
for case in range(t):
	(n, x) = (int(i) for i in input().split())
	if n in [1, 2]:
		output.append('1')
	elif n > 2:
		floor = (n - 3) // x + 2
		output.append(str(floor))
print('\n'.join(output))


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split())
	if n >= 2:
		q = 0
		if (n - 2) % x != 0:
			q = 1
		print(1 + (n - 2) // x + q)
	else:
		print(1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		c = 1
		m = 2
		while m < n:
			m += x
			c += 1
		print(c)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		floor = 2
		curr = 3
		while True:
			if curr <= n < curr + x:
				break
			else:
				curr += x
				floor += 1
		print(floor)


t = int(input())
for _ in range(0, t):
	(n, x) = map(int, input().split())
	if n == 1:
		print(1)
	else:
		a = []
		a.append(2)
		for i in range(1, 10 ** 4):
			if a[-1] + x <= n:
				a.append(a[-1] + x)
			else:
				a.append(a[-1] + x)
				break
		if n in a:
			print(len(a) - 1)
		else:
			print(len(a))


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, x) = [int(i) for i in input().split()]
	if n <= 2:
		print(1)
		continue
	n -= 2
	res = 1
	while n > 0:
		n -= x
		res += 1
	print(res)


tsts = int(input())
for i in range(tsts):
	inplst = input().split(' ')
	petya_num = int(inplst[0])
	each_flr = int(inplst[1])
	flr = 1
	tmp = 2
	while tmp < petya_num:
		tmp = tmp + each_flr
		flr = flr + 1
	print(flr)


from math import ceil
for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print('1')
	else:
		m = ceil((n - 2) / x)
		m += 1
		print(m)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(n, x) = map(int, sys.stdin.readline().split(' '))
	if n <= 2:
		print(1)
	else:
		floor = 1
		n -= 2
		while n > x:
			n -= x
			floor += 1
		print(floor + 1)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(n, x) = map(int, sys.stdin.readline().split())
	if n <= 2:
		print(1)
		continue
	print((n - 3) // x + 2)


import math
t = int(input())
while t > 0:
	t -= 1
	l = list(map(int, input().split()))
	(n, x) = (l[0], l[1])
	if n < 3:
		print(1)
		continue
	p = (n - 2) / x
	print(int(math.ceil(p) + 1))


def get_floor(n, x):
	if n <= 2:
		return 1
	for i in range(1000):
		if n >= i * x + 3 and n <= (i + 1) * x + 2:
			return i + 2
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	print(get_floor(n, x))


t = int(input())
for i in range(0, t):
	(m, n) = map(int, input().split())
	if m == 1 or m == 2:
		ans = 1
	else:
		x = m - 2
		if x % n == 0:
			y = int(x / n)
			ans = y + 1
		else:
			y = int(x / n) + 1
			ans = y + 1
	print(ans)


t = int(input())
s = 0
for i in range(t):
	s = 0
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		s += (n - 2) // x
		if (n - 2) % x != 0:
			s += 1
		s += 1
		print(s)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ans = 1
	val = 2
	while n > val:
		ans += 1
		val += x
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = (int(it) for it in input().split())
	if n < 3:
		print('1')
	else:
		print((n - 3) // x + 2)


t = int(input())
while t != 0:
	t -= 1
	(n, m) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	n = n - 2
	ans = 1
	if n % m == 0:
		ans += n // m
	else:
		ans += n // m + 1
	print(ans)


a = int(input())
n = {}
kol = {}
e = {}
for i in range(a):
	b = input().split(' ')
	n[i] = int(b[0])
	kol[i] = int(b[1])
	if n[i] > 2:
		e[i] = int((n[i] - 2) / kol[i]) + 1
		if int(n[i] - 2) % kol[i] != 0:
			e[i] += 1
	else:
		e[i] = 1
for i in range(a):
	print(e[i])


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	res = 1
	for i in range(1, 10001):
		if n <= i * k + 2:
			break
		res += 1
	print(res + 1)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	last = 2
	room = 1
	while last < n:
		last += x
		room += 1
	print(room)
	t -= 1


def fl(n, x):
	if n < 2:
		return 1
	if (n - 2) % x == 0:
		return int((n - 2) / x + 1)
	return int((n - 2) / x + 2)
t = int(input())
list = []
for i in range(t):
	(n, x) = input().split()
	list.append(fl(int(n), int(x)))
for i in range(t):
	print(list[i])


import math
for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		n1 = n - 2
		a = math.ceil(n1 / x)
		print(a + 1)


t = int(input())
for k in range(t):
	z = list(map(int, input().split()))
	kol = z[0]
	num = z[1]
	if kol <= 2:
		print(1)
	else:
		print((kol - 3) // num + 2)


def solve(n, x):
	if n <= 2:
		return 1
	if (n - 2) % x == 0:
		return 1 + (n - 2) // x
	return 2 + (n - 2) // x
t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	print(solve(n, x))
	t -= 1


t = int(input())
from math import ceil
while t > 0:
	(n, x) = list(map(int, input().split()))
	if n > 2:
		print(ceil((n - 2) / x) + 1)
	else:
		print(1)
	t -= 1


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	ans = 2
	v = 1
	if n <= 2:
		print(1)
	else:
		for i in range(n - 2):
			v += 1
			ans += x
			if ans >= n:
				print(v)
				break


import sys
import math
from collections import Counter
from collections import OrderedDict

def inputt():
	return sys.stdin.readline().strip()

def printt(n):
	sys.stdout.write(str(n) + '\n')

def listt():
	return [int(i) for i in inputt().split()]

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b / gcd(a, b)

def dfs(src, visit):
	visit[src] = 1
	for nbr in dic[src]:
		if visit[nbr] == 0:
			dfs(nbr, visit)
t = int(inputt())
for _ in range(t):
	(n, k) = map(int, inputt().split())
	if n == 1:
		printt(1)
	else:
		n = n - 2
		ans = math.ceil(n / k)
		printt(ans + 1)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(n, x) = invr()
	if n <= 2:
		print(1)
	else:
		ans = 2 + (n - 3) // x
		print(ans)


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict, Counter
from os import path
from bisect import bisect_left
import heapq
mod = 10 ** 9 + 7

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def inp():
		return int(input())

	def minp():
		return map(int, input().split())
else:

	def inp():
		return int(stdin.readline())

	def minp():
		return map(int, stdin.readline().split())
for _ in range(inp()):
	(n, x) = minp()
	if n == 1 or n == 2:
		print(1)
		continue
	n -= 2
	print(math.ceil(n / x) + 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	count = 1
	if n <= 2:
		print(count)
	else:
		f = 2
		while f < n:
			f += x
			count += 1
		print(count)


from collections import *
from heapq import *
from math import *
t = int(input())
while t:
	t -= 1
	(n, x) = [int(x) for x in input().split()]
	if n <= 2:
		print(1)
	else:
		n -= 2
		print(1 + ceil(n / x))


import math
n = int(input())
for _ in range(n):
	c = 1
	(a, b) = map(int, input().split())
	a -= 2
	if a > 0:
		c += math.ceil(a / b)
	print(c)


from math import ceil
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ans = 1
	f = 0
	p1 = 1
	p2 = 2
	while f == 0:
		if p1 <= n and n <= p2:
			f = 1
		else:
			ans += 1
			p1 = p2 + 1
			p2 = p2 + x
	print(ans)


t = input()
t = int(t)
for i in range(t):
	(n, x) = input().split(' ')
	n = int(n)
	x = int(x)
	x1 = n - 2
	if n <= 2:
		print(1)
		continue
	else:
		x2 = x1 / x
		if x2.is_integer():
			x2 = int(x2)
		else:
			x2 = int(x2) + 1
		print(x2 + 1)


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '5\n7 3\n1 5\n22 5\n987 13\n1 1\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield sys.stdin.readline()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def solve(n, x):
	if n <= 2:
		return (1,)
	return ((n - 2 + (x - 1)) // x + 1,)
t = getType(int)
for _ in range(t):
	(n, x) = getArray(int)
	res = solve(n, x)
	print(*res)


try:
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split(' '))
		apart = []
		floor = 0
		l = [1, 2]
		apart.append(l)
		i = 3
		while i <= n:
			li = [item for item in range(i, i + x)]
			apart.append(li)
			i += x
		for (i, j) in enumerate(apart):
			if i == 0:
				if i + 1 <= n <= i + 2:
					floor = i + 1
			elif apart[i][0] <= n <= apart[i][x - 1]:
				floor = i + 1
		print(floor)
except:
	pass


import math
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		count = 1
		n = n - 2
		while n > 0:
			n = n - x
			count += 1
		print(count)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		M = 2
		for floor in range(2, 2000):
			M += x
			if n <= M:
				print(floor)
				break


import math
t = int(input())
while t:
	t = t - 1
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	print(math.ceil((n - 2) / x) + 1)


for j in range(int(input())):
	(n, k) = map(int, input().split())
	if n > 1:
		a = (n - 2) // k
		b = (n - 2) % k
		print(a + 1 + (1 if b > 0 else 0))
	else:
		print(1)


import sys
input = sys.stdin.readline

def solve():
	(n, m) = map(int, input().split())
	if n <= 2:
		print(1)
		return
	print(1 + (n - 2 + m - 1) // m)
for _ in range(int(input())):
	solve()


import math
import re
import itertools
import copy
import time
import sys
import functools

def input_linear(lamb=lambda x: int(x), seperator=' '):
	return map(lamb, input().split(seperator))

def input_array(lamb=lambda x: int(x), seperator=' '):
	return list(map(lamb, input().split(seperator)))

def input_matrix(rows, lamb=lambda x: int(x), seperator=' '):
	tmp_matrix = []
	for i in range(rows):
		tmp_matrix.append(input_array(lamb, seperator))
	return tmp_matrix

def input_graph_al_pair(vertices, lines, lamb=lambda x: int(x), seperator=' ', directional=False, remove_dup=False):
	temp_matrix = [x[:] for x in [[]] * vertices]
	if not directional:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
				temp_matrix[inb].append(ina)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
				if ina not in temp_matrix[inb]:
					temp_matrix[inb].append(ina)
		return temp_matrix
	else:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
		return temp_matrix

def prettyp(a, typ='trash'):
	h = math.ceil(math.log(len(a), 2))
	for i in range(h):
		print(''.join(['  '] * (h - i)) + '  '.join(map(str, a[(1 << i) - 1:(1 << i + 1) - 1])))

def build_segment_t(a, lamb=lambda x, y: x + y):
	arr = [0] * len(a) + a.copy()
	for i in range(len(a) - 1, 0, -1):
		arr[i] = lamb(arr[i << 1], arr[i << 1 | 1])
	return arr

def mod_seg(a, pos, val):
	pos += len(a)
	a[pos] = val
	while pos > 1:
		a[pos >> 1] = a[pos] + a[pos ^ 1]
		pos >>= 1
for _ in range(int(input())):
	(n, x) = input_linear()
	if n < 3:
		print(1)
	else:
		r = 0
		while not r * x + 2 < n < (r + 1) * x + 3:
			r += 1
		print(r + 2)


kl = int(input())
for i in range(kl):
	(n, k) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print((n + k - 3) // k + 1)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if 1 <= n <= 2:
		print(1)
	else:
		n -= 2
		k = n / x
		if k % 1 != 0:
			k += 1
		k = int(k)
		print(k + 1)


t = int(input())
while t > 0:
	(n, x) = list(map(int, input().split()))
	apartment = 1
	i = 0
	if n == 1 or n == 2:
		print(apartment, end=' ')
	elif n in range(3, x + 2 + 1):
		apartment = 2
		print(apartment, end=' ')
	else:
		while True:
			i = i + 1
			apartment = apartment + 1
			if n in range((i - 1) * x + 3, i * x + 2 + 1):
				print(apartment, end=' ')
				break
	t = t - 1


def find_floor():
	t = int(input())
	while t > 0:
		arr = input().split(' ')
		(n, x) = (int(arr[0]), int(arr[1]))
		z = n - 2
		y = z // x
		if n <= 2:
			print(1)
		elif z - y * x == 0:
			print(y + 1)
		else:
			print(y + 2)
		t = t - 1
find_floor()


from sys import stdin, stdout
input = stdin.readline
from collections import defaultdict as dd
import math

def geti():
	return map(int, input().strip().split())

def getl():
	return list(map(int, input().strip().split()))

def gets():
	return input()

def geta():
	return int(input())

def print_s(s):
	stdout.write(s + '\n')

def solve():
	for _ in range(geta()):
		(n, k) = geti()
		n -= 2
		ans = 1
		while n > 0:
			ans += 1
			n -= k
		print(ans)
solve()


from math import ceil
for i in range(int(input())):
	(n, x) = map(int, input().split())
	m = 2
	c = 1
	while m < n:
		m = m + x
		c = c + 1
	print(c)


inp = lambda : int(input())
seq = lambda : list(map(int, input().strip().split()))

def results(n, x):
	if n <= 2:
		return 1
	else:
		n -= 2
		if n // x < n / x:
			return n // x + 2
		else:
			return n // x + 1

def main():
	t = inp()
	for _ in range(t):
		nx = seq()
		(n, x) = (nx[0], nx[1])
		result = results(n, x)
		print(result)
main()


import math
n = int(input())
anw = []
for _ in range(n):
	(m, x) = [int(x) for x in input().split()]
	if m <= 2:
		anw.append(1)
	else:
		anw.append(math.ceil((m - 2) / x) + 1)
for i in anw:
	print(i)


t = int(input())
for test in range(t):
	(n, x) = [int(_) for _ in input().split()]
	if n <= 2:
		print(1)
	else:
		n -= 3
		print(n // x + 2)


t = int(input())
arr = []
for i in range(0, t):
	last_apNo = 2
	(apNo, ap_count) = list(map(int, input().split()))
	floor = 0
	while 1:
		if apNo <= last_apNo:
			arr.append(floor + 1)
			break
		else:
			floor += 1
			last_apNo = floor * ap_count + 2
for k in arr:
	print(k)


from bisect import *
from collections import *
from random import *
from decimal import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	(n, x) = ma()
	fl = 1
	cu = 2
	while cu < n:
		cu += x
		fl += 1
	print(fl)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		cnt = 1
		sum = 2
		ans = 0
		while ans != 1:
			sum += x
			cnt += 1
			if sum >= n:
				print(cnt)
				ans = 1


import math as m
t = int(input())
for xyz in range(t):
	(n, x) = (int(i) for i in input().split())
	if n == 1 or n == 2:
		print('1')
	else:
		n = n - 2
		a = n / x
		b = m.ceil(a) + 1
		print(b)


t = input()
t = int(t)
for i in range(t):
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	count = 0
	r = 1
	s = 0
	if n == 1 or n == 2:
		print(1)
	else:
		for i in range(n):
			a = 3 + i * x
			b = r * x + 2
			r += 1
			if n >= a and n <= b:
				count += 1
				break
			count += 1
		print(count + 1)


import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		n = n - 2
		f = math.ceil(float(n) / x) + 1
		print(f)


t = int(input())
for i in range(t):
	(p, a) = [int(i) for i in input().split()]
	if p in [1, 2]:
		print(1)
	else:
		print((p - 3) // a + 2)


import math
test = int(input())
for k in range(test):
	(n, m) = list(map(int, input().split()))
	if n <= 2:
		print(1)
	else:
		print(math.ceil((n - 2) / m) + 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	out = 1
	n -= 2
	if n > 0:
		out += n // x
		n %= x
		if n > 0:
			out += 1
	print(out)


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()

def test():
	(n, x) = map(int, input().split())
	if n < 3:
		return 1
	else:
		return (n - 3) // x + 2
t = int(input())
for _ in range(t):
	print(test())


from math import ceil
t = int(input())
for i in range(t):
	(apartment, room_per_floor) = list(map(int, input().split()))
	if apartment <= 2:
		print(1)
	else:
		a = ceil((apartment - 2) / room_per_floor)
		print(a + 1)


import math
T = int(input())
while T > 0:
	(n, x) = [int(i) for i in input().split()]
	if n <= 2:
		print(1)
	else:
		print(1 + math.ceil((n - 2) / x))
	T -= 1


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		ans = 1
	else:
		ans = math.ceil((n - 2) / x)
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	tmp = (n - 2) % x
	if tmp != 0:
		tmp = (n - 2) // x + 1
	else:
		tmp = (n - 2) // x
	if tmp < 0:
		tmp = 0
	print(tmp + 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	y = n - 2
	if n == 1 or n == 2:
		print(1)
	else:
		Y = y / x - y // x
		ans = 0
		if Y != 0.0:
			ans += 1
		ans += y // x
		print(ans + 1)


for x in range(int(input())):
	a = list(map(int, input().split()))
	n = a[0]
	x = a[-1]
	count = 0
	i = 0
	s = 0
	while s < n:
		if i == 0:
			s = 2
			count += 1
		else:
			s = i * x + 2
			count += 1
		i += 1
	print(count)


def floor(n, x):
	if n <= 2:
		return 1
	else:
		ans = 2
		i = 2 + x
		while True:
			if n <= i:
				return ans
			else:
				i += x
				ans += 1
t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	n = a[0]
	x = a[1]
	print(floor(n, x))


testcases = int(input())
for _ in range(testcases):
	(n, x) = map(int, input().split())
	apartments = 2
	floor = 1
	while True:
		if n <= apartments:
			print(floor)
			break
		else:
			floor += 1
			apartments += x


t = int(input())
w = []
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	if n < 3:
		w.append(1)
	elif (n - 2) % x == 0:
		w.append(1 + (n - 2) // x)
	else:
		w.append(2 + (n - 2) // x)
for i in w:
	print(i)


import sys
import math
t = int(input())
for i in range(t):
	line = sys.stdin.readline().strip()
	values = list(map(int, line.split()))
	if values[0] < 2:
		print(1)
	else:
		print(int(math.ceil((values[0] - 2) / values[1]) + 1))


import os
import math
from functools import reduce
is_dev = 'vscode' in os.environ
if is_dev:
	inF = open('in.txt', 'r')
	outF = open('out.txt', 'w')

def ins():
	return list(map(int, input_().split(' ')))

def inss():
	return list(input_().split(' '))

def input_():
	if is_dev:
		return inF.readline()[:-1]
	else:
		return input()

def ranin():
	return range(int(input_()))

def print_(data):
	if is_dev:
		outF.write(str(data) + '\n')
	else:
		print(data)
for _ in ranin():
	(n, x) = ins()
	if n <= 2:
		print_(1)
	else:
		n -= 2
		n = math.ceil(n / x)
		print_(n + 1)
if is_dev:
	outF.close()

	def compare_file():
		print(open('out.txt', 'r').read() == open('outactual.txt', 'r').read())
	compare_file()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		num_of_apartment = 2
		floor = 1
		while num_of_apartment <= n:
			num_of_apartment += x
			if num_of_apartment == n:
				pass
			else:
				floor += 1
		print(floor)


for _ in range(int(input())):
	n = input().split()
	a = int(n[0]) - 2
	b = int(n[1])
	total = 1
	if a <= 0:
		total = 1
	elif a % b != 0:
		total += a // b + 1
	else:
		total += a // b
	print(total)


import sys
import math as m
t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	ans = (n - 2) // x
	ans += 2 if (n - 2) % x != 0 else 1
	if n - 2 <= 0:
		print('1')
	else:
		print(ans)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(n, x) = In()
		ans = math.ceil((n - 2) / x)
		if ans <= 0:
			print(1)
		else:
			print(ans + 1)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	n -= 2
	floor = n // x
	if floor * x == n:
		print(int(floor + 1))
	else:
		print(int(floor + 2))


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 2:
		print(1)
	else:
		n -= 2
		print(ceil(n / x) + 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	ans = (n + 2 * x - 3) // x
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	cnt = 2
	floor = 1
	while cnt < n:
		floor += 1
		cnt += x
	print(floor)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	elif n >= 3 and n <= x + 2:
		print(2)
	else:
		l = x + 3
		r = 2 * x + 2
		diff = r - l
		ans = 3
		while True:
			if n >= l and n <= r:
				print(ans)
				break
			else:
				l = r + 1
				r += diff + 1
				ans += 1


for i in range(int(input())):
	s = input().split()
	n = int(s[0])
	x = int(s[1])
	if n <= 2:
		print(1)
	else:
		l = (n - 2) % x
		if l == 0:
			print((n - 2) // x + 1)
		else:
			print((n - 2) // x + 2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n in (1, 2):
		print(1)
	else:
		k = 2
		floor = 1
		while k < n:
			k += x
			floor += 1
		print(floor)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	floor = 1
	q = n // x
	r = n % x
	if n == 1 or n == 2:
		print(floor)
	elif x == 2:
		k = n // 2
		if n % 2 == 0:
			print(k)
		else:
			print(k + 1)
	elif x == 1:
		print(n - 1)
	elif r == 0 or r == 1 or r == 2:
		print(floor + q)
	else:
		print(floor + q + 1)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a <= 2:
		print(1)
	else:
		a -= 2
		(x, y) = divmod(a, b)
		if y:
			print(x + 2)
		else:
			print(x + 1)


from math import ceil
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	c = 1
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		print(c + ceil(n / m))


t = int(input())
n_array = []
x_array = []
for i in range(t):
	temp = list(map(int, input().split()))
	n_array.append(temp[0])
	x_array.append(temp[1])
for i in range(t):
	n = n_array[i]
	x = x_array[i]
	if n == 1 or n == 2:
		print('1')
	elif (n - 2) / x == int((n - 2) / x):
		print(int((n - 2) / x) + 1)
	else:
		print(int((n - 2) / x) + 2)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	print(max(0, (n - 3) // x + 1) + 1)


from random import randint
import math

def solve(n, x):
	if n <= 2:
		return 1
	else:
		n = n - 2
		res = math.ceil(n / x) + 1
		return res
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print(solve(n, x))


def rl():
	return list(map(int, input().split()))

def arp(arr):
	return ' '.join([str(i) for i in arr])
from collections import deque, Counter
from math import ceil, sqrt, log2, log, floor
for _ in range(int(input())):
	(n, x) = rl()
	if n <= 2:
		print(1)
	else:
		print(ceil((n - 2) / x) + 1)


import math
a = int(input())
res = []
for c in range(a):
	(a, b) = map(int, input().split())
	if a <= 2:
		m = 1
		res.append(m)
	else:
		c = math.ceil((a - 2) / b) + 1
		res.append(c)
for x in res:
	print(x)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c for j in range(b)] for i in range(a)]

def list3d(a, b, c, d):
	return [[[d for k in range(c)] for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
for _ in range(INT()):
	(N, x) = MAP()
	N -= 2
	ans = 1
	while N > 0:
		N -= x
		ans += 1
	print(ans)


from enum import *
from copy import *
from sys import *
from collections import *
from itertools import *
from functools import *
from math import *

def l2i(fr=None):
	return map_type_to_fr(int, fr)[0]

def i2i(fr=None):
	return l2i(fr)

def dbg(*args):
	print(*args, file=stderr)

def dbv(var_name):
	print(f'{var_name} = {eval(var_name)}', file=stderr)

def map_type_to_fr(t, fr):
	global GETLINE_OFFSET
	if fr is None:
		if RUNNING_ON_MY_PC:
			fr = TEST_INP[GETLINE_OFFSET].split()
			GETLINE_OFFSET += 1
		else:
			fr = input().split()
	return list(map(t, fr))

def mis(fr=None):
	return map_type_to_fr(int, fr)

def mbs(fr=None):
	return map_type_to_fr(bool, fr)

def gs(fr=None):
	return map_type_to_fr(str, fr)[0]

def en(col):
	return enumerate(col)

def rn(*args):
	return range(*args)
import os
import sysconfig
RUNNING_ON_MY_PC = os.name == 'nt' and platform == 'win32' and (sysconfig.get_platform() == 'win-amd64')
GETLINE_OFFSET = 0
TEST_INP = '4\n7 3\n1 5\n22 5\n987 13\n\n'.split('\n')

def my_r(x):
	c = ceil(x)
	if c - x > 0.5:
		return floor(x)
	return c
for _ in range(i2i()):
	(n, x) = mis()
	if n in [1, 2]:
		print(1)
		continue
	print((n - 2) // x + 1 + (1 if (n - 2) % x != 0 else 0))


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
for t_c_ in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	if n <= 2:
		print(1)
	else:
		ans = (n - 2 + x - 1) // x + 1
		print(ans)


n = int(input())
l = []
for i in range(n):
	a = 0
	(t, x) = input().split()
	t = int(t)
	x = int(x)
	while True:
		if t <= a * x + 2:
			break
		else:
			a += 1
	l.append(a + 1)
for i in l:
	print(i)


def solve(n, x):
	if n - 2 < 0:
		print(1)
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	solve(n, x)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	(n, x) = rinput()
	if n <= 2:
		print(1)
		continue
	floor = 0
	while 1:
		if n >= floor * x + 3 and n <= (floor + 1) * x + 2:
			print(floor + 2)
			break
		floor += 1


for tc in range(int(input())):
	(apartment, number) = map(int, input().split())
	ans = 1
	if apartment <= 2:
		print(1)
		continue
	else:
		num = 2
		while num < apartment:
			num += number
			ans += 1
		print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	floor = 1
	aps = 2
	while aps < n:
		aps += x
		floor += 1
	print(floor)


import math
t = int(input())
for i in range(t):
	array = input()
	array1 = list(array.split(' '))
	n = int(array1[0])
	x = int(array1[1])
	h = math.floor((n - 3) / x)
	if h >= 0:
		print(h + 2)
	else:
		print(1)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	count = 1
	for floor in range(0, n):
		mn = floor * x + 3
		mx = floor * x + x + 2
		if n == 1 or n == 2:
			print('1')
			break
		elif mn <= n <= mx:
			print(floor + 2)
			break
	t = t - 1


def floor_number(x, n):
	v = False
	i = 0
	if n == 1 or n == 2:
		return 1
	else:
		while v == False:
			if n in range(i * x + 3, (i + 1) * x + 2 + 1):
				v = True
				return i + 2
			else:
				i += 1
t = int(input())
L = []
for j in range(t):
	(n, x) = map(int, input().split(' '))
	L.append(floor_number(x, n))
for k in range(len(L)):
	print(L[k])


import math

def solve(n, x):
	if n <= 2:
		return 1
	return math.ceil((n - 2) / x) + 1
t = int(input())
for _ in range(t):
	(n, x) = (int(a) for a in input().split())
	result = solve(n, x)
	print(result)


test_cases = int(input())
for i in range(test_cases):
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	if n == 1 or n == 2:
		print(1)
	else:
		div = (n - 3) // x
		print(div + 2)


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		if n % x == 0:
			print(n // x + 1)
		else:
			print(n // x + 2)


def floor(a, b):
	a = int(a)
	b = int(b)
	if a == 1 or a == 2:
		return 1
	elif (a - 2) % b == 0:
		return (a - 2) // b + 1
	else:
		return (a - 2) // b + 2
n = int(input())
d = []
for i in range(n):
	(a, b) = map(int, input().split())
	c = floor(a, b)
	d.append(c)
for i in range(n):
	print(d[i])


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		ans = 1
		s = 2
		while True:
			if s >= n:
				break
			s += x
			ans += 1
		print(ans)


def iinput():
	return [int(i) for i in input().split()]

def solve(n, x):
	ans = 1
	if n <= 2:
		return ans
	n -= 2
	ans += (n + x - 1) // x
	return ans
t = int(input())
for _ in range(t):
	(n, x) = iinput()
	print(solve(n, x))


import random, math, sys
from copy import deepcopy as dc
from bisect import bisect_left, bisect_right
from collections import Counter
input = sys.stdin.readline

def solution(n, x):
	if n <= 2:
		return 1
	return math.ceil((n - 2) / x) + 1

def input_test():
	for _ in range(int(input())):
		(n, x) = map(int, input().strip().split(' '))
		print(solution(n, x))

def test():
	pass
input_test()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print('1')
		continue
	temp = 2
	floor = 1
	while temp != n:
		floor += 1
		for i in range(x):
			temp += 1
			if temp == n:
				break
	print(floor)


def main():
	(n, x) = list(map(int, input().split()))
	if n == 1 or n == 2:
		return print(1)
	for i in range(1000):
		if n <= (i - 1) * x + 2 and n >= (i - 2) * x + 3:
			return print(i)
for i in range(int(input())):
	main()


t = int(input())
while t > 0:
	a = list(map(int, input().split()))
	n = a[0]
	x = a[1]
	if n > 0 and n <= 2:
		print('1')
	else:
		for i in range(1, n):
			res = i * x + 2
			if res >= n:
				break
		print(i + 1)
	t -= 1


t = int(input())
for i in range(t):
	main = []
	(n, x) = list(map(int, input().split()))
	main.append([1, 2])
	if n == 1 or n == 2:
		print(1)
	for j in range(n):
		la = []
		first = j * x + 3
		second = (j + 1) * x + 2
		la.append(first)
		la.append(second)
		main.append(la)
		if first <= n and n <= second:
			print(len(main))
		continue


t = int(input())
while t > 0:
	t = t - 1
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		z = 2
		c = 1
		while True:
			z = z + x
			c = c + 1
			if z >= n:
				break
		print(c)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		ans = (n - 3) // x + 2
		print(ans)
	t -= 1


import sys
from math import ceil
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	n -= 2
	ans = int(ceil(n / x)) + 1
	print(ans)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def msi():
	return map(str, input().split())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // gcd(x, y)
mod = 1000000007

def modInverse(b, m):
	g = gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def modu(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -999999999
	else:
		return inv * a % m
from math import log, sqrt, factorial, cos, tan, sin, radians, floor, log2
import bisect
from decimal import *
getcontext().prec = 8
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def fn(n):
	c = 0
	while n % 2 == 0:
		c += 1
		n //= 2
	return c

def main():
	for _ in range(ii()):
		(n, x) = mi()
		if n <= 2:
			print(1)
		else:
			ans = n - 2
			ans = ceil(ans, x)
			print(ans + 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math

def main():
	test_cases = int(input())
	while test_cases > 0:
		(t, x) = list(map(lambda x: int(x), input().split(' ')))
		if t <= 2:
			print(1)
		else:
			print(math.ceil((t - 2) / x) + 1)
		test_cases -= 1
	exit()
main()


def lift(n, x):
	if n == 1 or n == 2:
		return 1
	left = 3
	right = x + 2
	etaj = 2
	while True:
		if n >= left and n <= right:
			return etaj
		else:
			left = left + x
			right = right + x
			etaj = etaj + 1
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	print(lift(n, x))


def gt():
	return list(map(int, input().split()))
(t,) = gt()
while t:
	t -= 1
	(n, x) = gt()
	print((n - 2 + x - 1) // x + 1 if n > 2 else 1)


t = int(input())
for _ in range(t):
	c = 1
	(n, x) = map(int, input().split())
	i = 3
	j = 1
	while i <= n:
		if n in [*range(i, i + x)]:
			c += j
			break
		i = i + x
		j += 1
	print(c)


t = int(input())
ans = []
for i in range(t):
	(n, x) = map(int, input().split())
	ans.append((n - 3) // x + 2)
for x in ans:
	if x < 1:
		print(1)
	else:
		print(x)


import math
t = int(input())
for c in range(t):
	i = input().split()
	n = int(i[0])
	x = int(i[1])
	d = int(math.ceil((n - 2) / x))
	if n > 2:
		print(d + 1)
	else:
		print('1')


t = int(input())
for z in range(t):
	(n, x) = [int(x) for x in input().split()]
	if n - 2 <= 0:
		print(1)
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		f = 1
		a = 2
		m = 1
		while a < n:
			a = m * x + 2
			m += 1
			f += 1
		print(f)


import sys
import math
x = int(sys.stdin.readline().rstrip())
for i in range(x):
	temp = sys.stdin.readline().rstrip().split()
	temp = map(int, temp)
	(apt, floor) = temp
	if apt <= 2:
		print(1)
	else:
		print(math.ceil((apt - 2) / floor) + 1)


def solution(n: int, x: int) -> int:
	currFloor = 1
	curr = 0
	for i in range(1, 1000000000000001):
		if i == 3:
			currFloor = 2
		if i == n:
			return currFloor
		if i > 2:
			curr += 1
		if curr == x:
			curr = 0
			currFloor += 1
t = int(input())
for _ in range(t):
	nandx = input().split()
	n = int(nandx[0])
	x = int(nandx[1])
	print(solution(n, x))


t = int(input())
ans = []
for i in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		ans.append(1)
		continue
	n = n - 2
	if n % x > 0:
		rem = 1
	else:
		rem = 0
	ans.append(1 + n // x + rem)
for i in ans:
	print(i)


t = int(input())
import math as m
for test in range(1, t + 1):
	(n, x) = [int(i) for i in input().split()]
	if n <= 2:
		print(1)
		continue
	else:
		n -= 2
		print(m.ceil(n / x) + 1)


from collections import defaultdict
import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(n, k) = get_ints()
	if n <= 2:
		print(1)
	else:
		print(math.ceil((n - 2) / k) + 1)


testcases = int(input())
for i in range(testcases):
	(n, x) = map(int, input().split())
	if n == 1:
		print('1')
	elif n == 2:
		print('1')
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	elif (n - 2) % x != 0:
		print((n - 2) // x + 2)


import math
n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	if a == 1 or a == 2:
		print(1)
	else:
		a = a - 2
		fl = math.ceil(a / b)
		print(fl + 1)


from collections import *
from functools import *
import math
import sys
inp = sys.stdin.readline
out = sys.stdout.write

def mi():
	return map(int, inp().split())

def li():
	return list(mi())

def ii():
	return int(inp())

def main():
	for _ in range(ii()):
		(n, x) = mi()
		if n == 1 or n == 2:
			print(1)
		else:
			ans = 1
			nn = 2
			while nn < n:
				nn += x
				ans += 1
			print(ans)
main()


no_cases = int(input())
for i in range(no_cases):
	inp = input()
	(n, x) = inp.split()
	(n, x) = (int(n), int(x))
	floor = 1
	if n <= 2:
		print(floor)
		continue
	else:
		n -= 2
		while n > 0:
			floor += 1
			n -= x
		print(floor)


from sys import stdin, stdout
n = stdin.readline().strip()
n = int(n)
arr = list()
arrTot = list()
for i in range(n):
	arr = [int(x) for x in stdin.readline().split()]
	arrTot.append(arr)
resp = list()
depaMayor = 0
pisoActual = 1
aumento = 0
pisoAmigo = 0
for i in range(n):
	depaMayor = 0
	pisoActual = 1
	aumento = arrTot[i][1]
	pisoAmigo = arrTot[i][0]
	if pisoAmigo < depaMayor + 2:
		resp.append(pisoActual)
		continue
	else:
		depaMayor += 2
		while pisoAmigo > depaMayor:
			depaMayor += aumento
			pisoActual += 1
		resp.append(pisoActual)
for cada in resp:
	print(cada)


import sys
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n - 2 <= 0:
		print(1)
		continue
	if (n - 2) % x == 0:
		e = 1
	else:
		e = 2
	print(int((n - 2) / x) + e)


import sys
t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	n -= 2
	f = 1
	if n <= 0:
		print(1)
	else:
		print(f + (n + x - 1) // x)


for _ in range(int(input())):
	(n, k) = [int(_) for _ in input().split()]
	if n == 1 or n == 2:
		print(1)
	elif (n - 2) % k == 0:
		print(int((n - 2) // k) + 1)
	else:
		print(int((n - 2) // k) + 2)


import sys
r = sys.stdin.readline
for _ in range(int(r())):
	(a, b) = map(int, r().split())
	if a <= 2:
		print(1)
	else:
		print((a - 3) // b + 2)


import math

def floor_number(n, x):
	if n < 3:
		return 1
	return math.ceil((n - 2) / x) + 1
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print(floor_number(n, x))


from sys import stdout, stdin
from collections import defaultdict, deque
import math
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		z = n // k
		r = n % k
		if r == 0:
			print(z + 1)
		else:
			print(z + 2)


t = int(input())
for i in range(t):
	s = input()
	l = s.split()
	a = int(l[0])
	b = int(l[1])
	if a <= 2:
		print('1')
	elif a <= 2 + b:
		print('2')
	else:
		c = 2 * b + 2 - (b + 2)
		a = a - (b + 2)
		if a % c == 0:
			print(a // c + 2)
		else:
			print(a // c + 3)


n = int(input())
for _ in range(n):
	(num, x) = tuple(map(int, input().split()))
	if num == 1 or num == 2:
		print(1)
		continue
	num = num - 2
	if num % x == 0:
		print(num // x + 1)
	else:
		print(num // x + 2)


import math
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 3
		ans = 1
		ans += n // x + 1
		print(ans)


def a(n, x):
	if n <= 2:
		return 1
	else:
		return (n + x - 3) // x + 1
t = int(input())
s = list()
for i in range(t):
	(n, x) = map(int, input().split())
	s.append(a(n, x))
for i in s:
	print(i)


for tc in range(int(input())):
	(n, x) = [int(X) for X in input().split()]
	ans = 1
	rooms = 2
	while n > rooms:
		ans += 1
		rooms += x
	print(ans)


import math
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ans = 2
	if n <= ans:
		print(1)
	else:
		for i in range(1, 1001):
			if n <= x * i + 2:
				print(ans)
				break
			ans += 1


import math
a = int(input())
for i in range(a):
	ans = 0
	(n, x) = map(int, input().split())
	if n <= 2:
		ans = 1
	else:
		ans = math.ceil((n - 2) / x) + 1
	print(ans)


m = int(input())
for i in range(m):
	(a, b) = input().split(' ')
	if int(a) == 1 or int(a) == 2:
		print(1)
	elif (int(a) - 2) % int(b) == 0:
		print((int(a) - 2) // int(b) + 1)
	else:
		print((int(a) - 2) // int(b) + 2)


import math
t = int(input())
arr = []
cnt = []
for i in range(t):
	s = input().split(' ')
	arr.append([int(s[0]), int(s[1])])
	if arr[i][0] > 2:
		cnt.append(math.ceil((arr[i][0] - 2) / arr[i][1]) + 1)
	else:
		cnt.append(1)
for i in cnt:
	print(i)


for T in range(int(input())):
	(n, x) = map(int, list(input().split()))
	if n <= 2:
		print(1)
	else:
		n -= 2
		print((n - 1) // x + 2)


from sys import stdin, stdout
import math
for _ in range(int(stdin.readline())):
	(n, x) = map(int, stdin.readline().split())
	if n - 2 <= 0:
		print(1)
	else:
		print(int(math.ceil((n - 2) / x)) + 1)


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
sys.setrecursionlimit(10 ** 5)

def mod():
	return 1000000007

def ii():
	return int(sys.stdin.readline())

def si():
	return sys.stdin.readline().strip()

def li():
	return list(sys.stdin.readline().strip())

def mii():
	return map(int, sys.stdin.readline().split())

def lii():
	return list(map(int, sys.stdin.readline().strip().split()))

def solve():
	(n, x) = mii()
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		print(1 + n // x + bool(n % x))
for _ in range(ii()):
	solve()


for i in range(int(input())):
	(n, x) = map(int, input().split())
	answer = 0
	if n < 3:
		print(1)
	else:
		n -= 2
		while True:
			answer += 1
			if n <= 0:
				print(answer)
				break
			n -= x


import math
t = int(input())
while t:
	(n, x) = list(map(int, input().split()))
	n = max(0, n - 2)
	print(math.ceil(n / x) + 1)
	t -= 1


q = int(input())
kv = 2
et = 1
for i in range(q):
	s = input().split()
	n = int(s[0])
	x = int(s[1])
	while kv < n:
		kv += x
		et += 1
	print(et)
	et = 1
	kv = 2


n = int(input())
for i in range(n):
	(n, x) = map(int, input().split(' '))
	if n == 1 or n == 2:
		print(1)
	else:
		max_point = 2
		key = False
		q = 1
		while not key:
			max_point += x
			q += 1
			if n <= max_point:
				key = True
				print(q)


for h in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		n = n - 2
		a = int(n / x) + 1
		if n % x != 0:
			a = a + 1
		print(a)


_list = []
n = int(input())
for i in range(0, n):
	_list.append(input().split(' '))

def Number_of_stage(n, x):
	if int(n) in range(1, 3):
		return 1
	else:
		for i in range(2, 1001):
			if n in range((i - 2) * x + 3, (i - 1) * x + 2 + 1):
				return i
for i in _list:
	print(Number_of_stage(int(i[0]), int(i[1])))


import sys
for _ in range(int(input())):
	k = 0
	(n, x) = map(int, input().split())
	for i in range(3, 1000000, x):
		k += 1
		if n < i:
			print(k)
			break


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	if n == 1 or n == 2:
		print(1)
	else:
		c = 2
		(a, b) = (3, x + 2)
		while True:
			if n in range(a, b + 1):
				break
			(a, b) = (a + x, b + x)
			c += 1
		print(c)


def find_floor(n, x):
	if n < 3:
		return 1
	k = int((n - 3) / x) + 2
	return k
t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	k = find_floor(n, x)
	print(k)


t = int(input())
for i in range(0, t):
	(n, x) = list(map(int, input().split()))
	sum = 2
	cnt = 1
	while True:
		if sum >= n:
			break
		sum += x
		cnt += 1
	print(cnt)


def inlt():
	return list(map(int, input().split()))
times = int(input())
for time in range(times):
	inp = inlt()
	ans = 0
	n = inp[0]
	x = inp[1]
	for i in range(1, n):
		if n <= i * x + 2:
			ans = i
			break
	if n <= 2:
		ans = 0
	print(ans + 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		piso = 2
		principio = 3
		final = x + 2
		while not final >= n >= principio:
			principio = (piso - 1) * x + 3
			final = piso * x + 2
			piso += 1
		print(piso)


casos = int(input())
for i in range(casos):
	lista = []
	for j in input().split(' '):
		lista.append(int(j))
	if lista[0] <= 2:
		print(1)
	else:
		planta = 1
		lista[0] -= 2
		planta += lista[0] / lista[1]
		if lista[0] % lista[1] != 0:
			planta += 1
		print(int(planta))


t = int(input())
k = 0
b = []
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		k += 1
		b.append(k)
	else:
		n -= 2
		k += 1
		while n > 0:
			n -= x
			k += 1
		b.append(k)
	k = 0
for i in range(t):
	print(b[i])


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, x) = list(map(int, input().split()))
	flag = 1
	for i in range(2, n, x):
		flag = flag + 1
	print(flag)


import sys

def solve():
	(n, x) = map(int, input().split())
	print(1 if n <= 2 else (n - 3) // x + 2)
t = int(input())
for _ in range(t):
	solve()


import sys
import math

def Int():
	return int(input())

def Str():
	return input()

def Ints():
	return map(int, input().split(' '))

def int_arr():
	return list(map(int, input().split(' ')))

def str_arr():
	return list(map(str, input().split(' ')))

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
testcases = Int()
for i in range(testcases):
	(room_no, each) = Ints()
	if room_no - 2 <= 0:
		print(1)
	else:
		room_no = room_no - 2
		if room_no % each != 0:
			print(room_no // each + 2)
		else:
			print(room_no // each + 1)


from math import log2
from functools import reduce

def readGenerator():
	while True:
		tokens = input().split(' ')
		for t in tokens:
			yield t
reader = readGenerator()

def readWord():
	return next(reader)

def readInt():
	return int(next(reader))

def readFloat():
	return float(next(reader))

def readLine():
	return input()

def solve(n, x):
	if n <= 2:
		return 1
	return (n - 3) // x + 2
t = readInt()
for _ in range(0, t):
	n = readInt()
	x = readInt()
	print(solve(n, x))


t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	flag = False
	e = 1
	if n <= 2:
		print(1)
		flag = True
	while not flag:
		if (e - 1) * x + 3 <= n <= e * x + 2:
			print(e + 1)
			flag = True
		e += 1


sz = 0
sz = int(input())

def Petya(sz):
	n = 0
	x = 0
	for i in range(sz):
		inputs = list(map(int, input().split()))
		n = int(inputs[0])
		x = int(inputs[1])
		if n < 3:
			print(1)
			continue
		n = n - 2
		ANS = n // x
		if n % x != 0:
			ANS += 1
		print(ANS + 1)
Petya(sz)


def floor_no(n, x):
	if n <= 2:
		return 1
	floor = (n - 2) // x
	if (n - 2) % x:
		ans = floor + 2
	else:
		ans = floor + 1
	return ans
t = int(input())
for _ in range(t):
	nx = input().split()
	n = int(nx[0])
	x = int(nx[1])
	print(floor_no(n, x))


import sys
import math
read = sys.stdin.readline

def solution(n, x):
	if n <= 2:
		return 1
	return math.ceil((n - 2) / x) + 1
t = int(read())
for _ in range(t):
	print(solution(*list(map(int, read().split()))))


import math
n1 = int(input())
for x in range(n1):
	n2 = input().split(' ')
	a = int(n2[0])
	b = int(n2[1])
	if a <= 2:
		print(1)
	else:
		print(1 + math.ceil((a - 2) / b))


def solution(n, x):
	temp = 1
	if n == 1:
		print('1')
	elif n == 2:
		print('1')
	else:
		while n > temp * x + 2:
			temp += 1
		temp += 1
		print(temp)
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	solution(n, x)


T = int(input())
for i in range(T):
	(n, x) = map(int, input().split())
	c = 2
	s = 1
	while c < n:
		c = c + x
		s = s + 1
	print(s)


for nt in range(int(input())):
	(a, b) = map(int, input().split())
	if a <= 2:
		print(1)
		continue
	print((a - 3) // b + 2)


import sys

def solve(x):
	print(x)
	return x
IN = [x.strip() for x in sys.stdin.readlines()]
T = int(IN[0])
for ti in range(T):
	(n, x) = [int(x) for x in IN[ti + 1].split(' ')]
	if n < 2:
		floor = 1
	else:
		floor = (n - 2 + x - 1) // x + 1
	print(floor)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		l = (n - 3) // x + 2
		print(l)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	count = 1
	if n == 1 or n == 2:
		print(1)
	elif n > 2:
		n = n - 2
		while n > 0:
			count += 1
			n -= x
		print(count)


def findFloor(n, x):
	if n == 1 or n == 2:
		return 1
	if (n - 2) % x == 0:
		return (n - 2) // x + 1
	else:
		return (n - 2) // x + 2
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	print(findFloor(n, x))


t = int(input())
data = list()
counter = 0
for i in range(t):
	data.append(input().split())
for i in range(t):
	for j in range(2):
		data[i][j] = int(data[i][j])
for i in range(t):
	if data[i][0] <= 2:
		print(1)
	else:
		for j in range(2, data[i][0]):
			if data[i][0] >= 3 + data[i][1] * (j - 2) and data[i][0] <= (j - 1) * data[i][1] + 2:
				print(j)


import sys
input = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	if n <= 2:
		print(1)
	else:
		print((n - 3) // x + 2)


def floor(ap_n, ap_f):
	floor = 1
	if ap_n == 1 or ap_n == 2:
		return floor
	else:
		floor = 2
		max_num_app = 2 + ap_f
		min_num_app = 3
		while True:
			if ap_n >= min_num_app and ap_n <= max_num_app:
				return floor
			else:
				floor += 1
				nim_num_app = max_num_app + 1
				max_num_app = max_num_app + ap_f
test_cases = int(input())
for i in range(0, test_cases):
	info = list(map(int, input().split()))
	apartment_number = info[0]
	number_apartments_per_floor = info[1]
	print(floor(apartment_number, number_apartments_per_floor))


import math
t = int(input())
for _ in range(t):
	ans = 0
	n = list(map(int, input().split()))
	n1 = n[0]
	n2 = n[1]
	ans = math.ceil((n1 - 2 + n2) / n2)
	if ans < 1:
		ans = 1
	print(ans)


for test_var in range(int(input())):
	(n, k) = map(int, input().split())
	x = 0
	if n <= 2:
		print(1)
	else:
		while True:
			if n <= x * k + 2:
				print(x + 1)
				break
			x += 1


from sys import stdin

def updiv(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1
tt = int(stdin.readline())
for loop in range(tt):
	(n, x) = map(int, stdin.readline().split())
	if n <= 2:
		print(1)
	else:
		print(updiv(n - 2, x) + 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	j = 2
	for i in range(2, n + 2):
		j += x
		if j >= n:
			print(i)
			break


def main():
	t = int(input())
	for i in range(t):
		(n, x) = map(int, input().split())
		if n <= 2:
			print(1)
		else:
			flat = 1
			n -= 2
			while n > 0:
				flat += 1
				n -= x
			print(flat)
	return 0
main()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	if n <= 2:
		print(1)
		continue
	else:
		count = 1
		n -= 2
		count += n // x
		if n % x != 0:
			count += 1
	print(count)


import math
testcase = int(input())
while testcase >= 1:
	(room, floor) = [int(i) for i in input().split()]
	if room > 2:
		print(math.ceil((room - 2) / floor) + 1)
	else:
		print(1)
	testcase -= 1


t = int(input())
for i in range(t):
	(number, nb_aparts) = map(int, input().split(' '))
	if number == 1 or number == 2:
		print(1)
	elif number >= 3 and number <= 2 + nb_aparts:
		print(2)
	else:
		h = 3
		while True:
			if 2 + (h - 1) * nb_aparts >= number and 2 + (h - 2) * nb_aparts <= number:
				print(h)
				break
			h += 1


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	(n, x) = sep()
	if n == 1 or n == 2:
		print(1)
		return
	n -= 2
	print(ceil(n / x) + 1)
testcase(int(inp()))


import math
for _ in range(int(input())):
	count = 2
	(n, x) = map(int, input().split())
	a = 3 + x
	if n in range(1, 3):
		print(1)
	elif n in range(3, x):
		print(2)
	else:
		n = n - 2
		print(1 + math.ceil(n / x))


import math
t = int(input())
while t > 0:
	(n, x) = [int(x) for x in input().split()]
	if n == 2 or n == 1:
		print('1')
	else:
		n = n - 2
		ans = 0
		ans += math.ceil(n / x) + 1
		print(ans)
	t -= 1


import math as m
for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		ans = m.ceil((n - 2) / x)
		print(ans + 1)


from sys import stdin
input = stdin.readline
for i in range(int(input())):
	(n, m) = map(int, input().split())
	print(1 if n <= 2 else (n - 3) // m + 2)


import math
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		ans = 2
		mpf = (ans - 1) * x + 2
		while mpf < n:
			ans += 1
			mpf = (ans - 1) * x + 2
		print(ans)


T = int(input())
for i in range(T):
	(N, Number) = input().split(' ')
	if int(N) == 1:
		print('1')
	elif (int(N) - 2) % int(Number) != 0:
		print((int(N) - 2) // int(Number) + 2)
	else:
		print((int(N) - 2) // int(Number) + 1)


def solution():
	t = int(input())
	for i in range(t):
		(n, x) = [int(i) for i in input().split()]
		if n <= 2:
			print(1)
		else:
			n -= 2
			res = n // x + 1
			if n % x > 0:
				res += 1
			print(res)
solution()


import math
teststring = '4\n7 3\n1 5\n22 5\n987 13\n'
online = __file__ != '/home/jhli/py/674/Problem_A.py'
(true, false) = (True, False)
if True:

	def spitout():
		for c in teststring.splitlines():
			yield c
	_ito = spitout()
	if not online:

		def input():
			return next(_ito)

	def build_enum(*a):
		built = dict()
		for (i, c) in enumerate(a):
			built[c] = i
		return lambda x: built[x]
T = int(input())
for ti in range(1, T + 1):
	[n, x] = map(int, input().split(' '))
	if n <= 2:
		print(1)
	else:
		print(int(math.ceil((n - 2) / x)) + 1)


import math
t = int(input())
for _ in range(0, t):
	ls = list(map(int, input().split()))
	n = ls[0]
	x = ls[1]
	if n < 3:
		print(1)
	else:
		n -= 2
		ans = math.ceil(n / x)
		print(ans + 1)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	stdin = lambda type_='int', sep=' ': list(map(eval(type_), input().split(sep)))
	t = int(input())
	for _ in range(t):
		(n, x) = stdin()
		if n <= 2:
			print(1)
			continue
		floor = 1 + (n - 2) // x + (1 if (n - 2) % x != 0 else 0)
		print(floor)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from typing import Counter
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		i = 3
		count = 2
		while 1:
			if n in range(i, i + x):
				print(count)
				break
			i = i + x
			count += 1


def ans(n, x):
	if n == 1 or n == 2:
		return 1
	cn = 2
	level = x + 2
	while True:
		if n <= level:
			return cn
		level += x
		cn += 1
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().rstrip().split())
	print(ans(n, x))


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	(n, x) = list(map(int, stdin.readline().rstrip().split()))
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		cnt = 1
		while n > 0:
			n -= x
			cnt += 1
		print(cnt)


t = int(input())
while t:
	(n, x) = map(int, input().split(' '))
	f = [[1, 2]]
	a = []
	c = 2
	while c < n:
		a = []
		for j in range(1, x + 1):
			a.append(c + j)
		f.append(a)
		c = f[-1][-1]
	print(len(f))
	t = t - 1


import sys
import math
for _ in range(int(input())):
	(n, t) = map(int, sys.stdin.readline().split())
	if n == 1 or n == 2:
		print('1')
	else:
		print(math.ceil((n - 2) / t) + 1)


import math
t = int(input())
for _ in range(t):
	(p, n) = list(map(int, input().rstrip().split()))
	if p <= 2:
		print(1)
	else:
		print(math.ceil((p - 2) / n) + 1)


import math

def docalc(numtup):
	n = numtup[1]
	m = numtup[0]
	if numtup[1] <= 2:
		return 1
	n = n - 2
	return math.ceil(n / m) + 1
num_pairs = int(input())
pairs = []
for i in range(num_pairs):
	instring = input()
	nums = instring.split()
	m = int(nums[0])
	n = int(nums[1])
	pairs.append((n, m))
for i in range(num_pairs):
	print(docalc(pairs[i]))


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	apart = 2
	floor = 1
	while apart < n:
		apart = apart + x
		floor += 1
	print(floor)


t = int(input(''))
for _ in range(t):
	[n, k] = list(map(int, input().split()))
	if n <= 2:
		print(1)
		continue
	baki = n - 2
	m = baki / k
	if m == int(m):
		print(int(m) + 1)
	else:
		print(int(m) + 2)


t = int(input())
new = []
for w in range(t):
	first = input('').split()
	new.append(first)
for ii in new:
	ii = [int(f) for f in ii]
	n = ii[0]
	x = ii[1]
	v = 0
	if n == 1 or n == 2:
		print(1)
	else:
		for i in range(2, 1000):
			if i == 2:
				v += x + 2
			else:
				v += x
			if v - n >= 0:
				print(i)
				break


def main():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		if n <= 2:
			print(1)
		else:
			n -= 3
			floor = n // x
			print(floor + 2)
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	floor = 1
	if n < 3:
		print('1')
	else:
		while n - 2 > 0:
			floor += 1
			n -= x
		print(floor)


for _ in range(int(input())):
	(n, x) = map(int, input().strip().split())
	floor = 1
	n -= 2
	while n > 0:
		floor += 1
		n -= x
	print(floor)


import sys
import os

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
	x

def take_input():
	if os.environ.get('check'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
take_input()
for _ in range(int(input())):
	(n, x) = int_array()
	if n <= 2:
		print(1)
	else:
		print(2 + (n - 3) // x)


def solve_a(n, x):
	if n < 3:
		return 1
	return (n - 3) // x + 2
t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	print(solve_a(n, x))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 1 or a == 2:
		print(1)
	if a >= 3:
		c = (a - 2) // b
		if (a - 2) % b != 0:
			print(c + 2)
		else:
			print(c + 1)


import math
from datetime import date
import sys
input = sys.stdin.readline

def main():
	t = int(input())
	while t > 0:
		t -= 1
		line = input().split()
		(n, k) = (int(line[0]), int(line[1]))
		if n <= 2:
			print(1)
		else:
			n -= 2
			print((n + k - 1) // k + 1)
main()


a = int(input())
from math import ceil
for i in range(a):
	(b, c) = map(int, input().split())
	if b == 1 or b == 2:
		print(1)
	else:
		print(ceil((b - 2) / c) + 1)


t = int(input().split()[0])
while t:
	s = input()
	(n, x) = (int(s.split()[0]), int(s.split()[1]))
	if n <= 2:
		print(1)
	else:
		n -= 2
		floor = n // x
		if n % x:
			floor += 1
		print(1 + floor)
	t -= 1


t = int(input())
for _ in range(t):
	p = input().split()
	n = int(p[0])
	x = int(p[1])
	n -= 2
	if n <= 0:
		print('1')
	else:
		z = n // x
		if n % x == 0:
			print(z + 1)
		else:
			print(z + 2)


def solve(n, x):
	if n == 1 or n == 2:
		return 1
	(floor, start) = (1, 3)
	while True:
		floor += 1
		start += x
		if start > n:
			return floor

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = list(map(int, input().split()))
		print(solve(n, x))
main()


a = []
y = int(input())
for i in range(y):
	nl = input().split()
	a.append(nl)
for i in a:
	n = int(i[0])
	x = int(i[1])
	if n >= 3:
		apart = [[1, 2]]
		my_list = []
		for j in range(3, n + 1):
			my_list.append(j)
		final = [my_list[i * x:(i + 1) * x] for i in range((len(my_list) + x - 1) // x)]
		for i in final:
			apart.append(i)
		print(len(apart))
	else:
		print(1)


l = []
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		l.append(1)
	else:
		n = n - 2
		if n % x == 0:
			l.append(n // x + 1)
		else:
			l.append(n // x + 2)
for i in l:
	print(i)


import math
for i in range(int(input())):
	l = list(map(int, list(input().split())))
	print(1 if l[0] <= 2 else math.ceil((l[0] - 2) / l[1]) + 1)


import math
a = int(input())
ans = list()
for i in range(0, a):
	(n, x) = map(int, input().split())
	if n <= 2:
		f = 1
	else:
		f = math.ceil(1 + (n - 2) / x)
	ans.append(f)
ans = map(str, ans)
print('\n'.join(ans))


def f(n, x):
	if n <= 2:
		return 1
	else:
		return 2 + (n - 3) // x
t = int(input())
output = []
for i in range(t):
	output.append(f(*[int(i) for i in input().split()]))
for i in range(t):
	print(output[i])


def piso(n: int, x: int) -> int:
	return 1 + ((n - 2) // x + (1 if (n - 2) % x > 0 else 0) if n > 2 else 0)
times = int(input())
answers = []
for _ in range(times):
	answers.append(piso(*map(int, input().strip().split())))
for n in answers:
	print(n)


t = int(input())
i = 0
g = 0
s = []
while i < t:
	(n, x) = input().split()
	i += 1
	if n == '1' or n == '2':
		s.append(1)
	elif (int(n) - 2) % int(x) == 0:
		s.append((int(n) - 2) // int(x) + 1)
	elif (int(n) - 2) % int(x) != 0:
		s.append((int(n) - 2) // int(x) + 2)
for g in range(0, i):
	print(s[g])


ans = []
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 2:
		a = 1
	else:
		a = (n + x - 3) // x + 1
	ans.append(str(a))
print('\n'.join(ans))


tests = int(input())
i = 0
while i < tests:
	(apt_num, apt_per_floor) = list(map(int, input().split()))
	floor_count = 0
	while apt_num > 0:
		if floor_count == 0:
			apt_num -= 2
		else:
			apt_num -= apt_per_floor
		floor_count += 1
	i += 1
	print(floor_count)


import math as m
t = int(input())
Listnx = []
for i in range(0, t):
	Listn = []
	nx = input()
	nxsplit = nx.split()
	n = int(nxsplit[0])
	x = int(nxsplit[1])
	Listn.append(n)
	Listn.append(x)
	Listnx.append(Listn)
for List in Listnx:
	if List[0] > 2:
		c = m.ceil((List[0] - 2) / List[1]) + 1
		print(c)
	else:
		print(1)


def floorNum(y, f):
	if y < 3:
		return 1
	elif y > 2 and (y - 2) % f == 0:
		z = (y - 2) // f
		return z + 1
	else:
		z = (y - 2) // f
		return z + 2
t = int(input())
for i in range(t):
	inp = input()
	case = inp.split()
	n = int(case[0])
	x = int(case[1])
	j = floorNum(n, x)
	print(j)


from sys import stdin
input = stdin.readline
for i in range(int(input())):
	(a, n) = map(int, input().split())
	if a == 1:
		print(1)
	if a == 2:
		print(1)
	elif a != 1 and a != 2:
		x = a - 2
		if x % n == 0:
			print(x // n + 1)
		elif x % n != 0:
			print(x // n + 2)


rw = int(input())
for wewq in range(rw):
	(n, x) = map(int, input().split())
	if n > 2:
		n -= 2
		print((n + x - 1) // x + 1)
	else:
		print(1)


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, x) = map(int, stdin.readline().rstrip().split())
	if n <= 2:
		print(1)
	elif x == 1:
		print(n - 1)
	elif (n - 2) % x == 0:
		n -= 2
		print(n // x + 1)
	else:
		n -= 2
		print(n // x + 2)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 2 or n == 1:
		print(1)
	else:
		for i in range(1, 1005):
			if n <= i * x + 2:
				print(i + 1)
				break


n = int(input())
c = 1
l = []
for i in range(n):
	(n, x) = map(int, input().split(' '))
	if n > 2:
		c = 1
		k = n - 2
		a = k // x
		b = k / x
		if b > a:
			c = a + c
			l.append(c + 1)
		elif b == a:
			c = a + c
			l.append(c)
	else:
		l.append(1)
print(*l, sep='\n')


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	res = 1
	if n > 2:
		res += (n - 2) // x
		if (n - 2) % x != 0:
			res += 1
	print(res)
	t -= 1


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	(n, k) = ip()
	if [n, k] == [1, 1]:
		print(1)
		continue
	ans = 1
	n -= 2
	ans += (n - 1) // k + 1
	print(ans)


from sys import stdin
import math

def get_int():
	return int(stdin.readline())

def get_str():
	return stdin.readline().strip()

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_array2d(row):
	return [list(map(int, stdin.readline().strip().split())) for _ in range(row)]
T = get_int()
for _ in range(T):
	(N, X) = get_ints()
	if N < 3:
		print(1)
	else:
		N -= 2
		ans = math.ceil(N / X) + 1
		print(ans)


import os
import sys
from io import BytesIO, IOBase
import math

def main1():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		if n <= 2:
			print(1)
		else:
			n -= 2
			print(1 + math.ceil(n / x))

def main2():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		flag = 0
		for i in range(n):
			mat = []
			for j in range(2):
				mat.append(list(map(int, input().split())))
			if mat[0][1] == mat[1][0]:
				flag = 1
		if m % 2 or flag == 0:
			print('NO')
		else:
			print('YES')

def main3():
	for _ in range(int(input())):
		n = int(input())
		ans = float('inf')
		for i in range(1, math.floor(math.sqrt(n)) + 1):
			ans = min(ans, i - 1 + (n - i + i - 1) // i)
		print(ans)

def main4():
	n = int(input())
	a = list(map(int, input().split()))
	ls = [0] * n
	ls[0] = a[0]
	for i in range(1, n):
		ls[i] = ls[i - 1] + a[i]
	ans = 0
	d = dict()
	d[0] = 0
	d[ls[0]] = 0
	prev_pos = 0
	for i in range(1, n):
		if ls[i] in d:
			pos = d[ls[i]] + 1
			if pos >= prev_pos:
				prev_pos = i
				ans += 1
		d[ls[i]] = i
	print(ans)

def main5():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	max_win = min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0])
	min_win = max(0, a[0] - b[0] - b[2]) + max(0, a[1] - b[1] - b[0]) + max(0, a[2] - b[2] - b[1])
	print(min_win, max_win)

def main6():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main1()


def solve():
	(n, x) = [int(v) for v in input().split()]
	if n <= 2:
		print(1)
		return
	l = 1
	r = n
	while l < r:
		m = l + (r - l) // 2
		if m * x + 2 < n:
			l = m + 1
		else:
			r = m
	print(l + 1)
t = int(input())
for _ in range(t):
	solve()


for test_cases in range(int(input())):
	[n, x] = list(map(int, input().split()))
	n = n - 2
	if x == 1:
		if n == -1 or n == 0:
			print(int(1))
		else:
			print(int(n + 1))
		continue
	if n % x == 0:
		print(int(n / x + 1))
		continue
	else:
		print(int(n // x + 2))
		continue


import math
n_tests = int(input())
for test in range(n_tests):
	(apt, n_apts) = [int(i) for i in input().split()]
	if apt <= 2:
		print('1')
	elif apt <= n_apts + 2:
		print('2')
	elif (apt - 2) % n_apts == 0:
		print(int((apt - 2) / n_apts + 1))
	else:
		print(int((apt - 2) / n_apts + 2))


import math
t = int(input())
while t:
	flag = 0
	(x, y) = map(int, input().split())
	if x == 1 or x == 2:
		flag = 1
	elif x > 2:
		z = math.floor((x - 3) / y)
		print(z + 2)
	if flag == 1:
		print(flag)
	t -= 1


test = int(input())
for _ in range(test):
	(n, x) = map(int, input().split())
	if n > 2:
		n -= 2
		mod = n % x
		print(n // x + 1 + (0 if mod == 0 else 1))
	else:
		print(1)


n = int(input())
for i in range(n):
	(n, x) = map(int, input().split())
	n1 = 2
	a = 1
	if n <= n1:
		print(1)
	else:
		while n1 != n and n1 < n:
			n1 = n1 + x
			a = a + 1
		print(a)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		ans = 1
		cur = 2
		while cur < n:
			ans += 1
			cur += x
		print(ans)


from sys import stdin, stdout

def read_input():
	lines = []
	for line in stdin:
		if 'exit' == line.lower().rstrip():
			break
		lines.append(line.rstrip())
	return lines

def floor(n, x):
	if n < 3:
		return 1
	n -= 2
	if n % x == 0:
		return n // x + 1
	else:
		return n // x + 2
data = read_input()
t = int(data[0])
for case in range(1, t + 1):
	(n, x) = [int(x) for x in data[case].split(' ')]
	stdout.write(str(floor(n, x)) + '\n')
stdout.flush()


tc = int(input())
for _ in range(tc):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		n = n - 2
		i = 1
		while n > 0:
			n = n - x
			i += 1
		print(i)


t = int(input())
for testcase in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print('1')
		continue
	else:
		n -= 2
		ans = 1
		p = n % x
		if p >= 1:
			ans = n // x
			ans = ans + 1
		else:
			ans = n // x
		print(ans + 1)


import math
t = int(input())
for test in range(t):
	(n, x) = [int(x) for x in input().split()]
	num = n - 2
	if n in [1, 2]:
		print(1)
	else:
		print(math.ceil(num / x) + 1)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	i = 1
	k = 2
	while k < a:
		k = k + b
		i = i + 1
	print(i)


t = int(input())

def nechanchi_qavat(n, x):
	if n == 1 or n == 2:
		return 1
	else:
		return (n + x - 3) // x + 1
natija = []
for i in range(t):
	(n, x) = input().split(' ')
	(n, x) = (int(n), int(x))
	natija.append(nechanchi_qavat(n, x))
for i in range(len(natija)):
	print(natija[i])


import math
import bisect
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
I = lambda : int(input())
tup = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
t = I()
while t:
	(n, x) = tup()
	if n <= 2:
		print(1)
	else:
		print(math.ceil((n - 2) / x) + 1)
	t -= 1


import math
a = int(input())
b = []
for i in range(a):
	b.append(list(map(int, input().split())))
out = []
for j in range(a):
	n = b[j][0]
	f = b[j][1]
	if n < 3:
		out.append(1)
		continue
	o = int(math.ceil((n - 2) / f)) + 1
	out.append(o)
for i in range(len(out)):
	print(out[i])


t = int(input())
while t:
	(n, k) = map(int, input().split())
	if n < 3:
		print(1)
		t -= 1
		continue
	f = int((n - 3) / k) + 2
	print(f)
	t -= 1


import math
n = int(input())
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	if a <= 2:
		print(1)
	else:
		print(math.ceil((a - 2) / b) + 1)


n = int(input())
for i in range(1, n + 1):
	(b, x) = map(int, input().split())
	k = 2
	c = 1
	while b > k:
		c = c + 1
		k = k + x
	print(c)


def result():
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	ans = True
	floor = 1
	ll = 0
	ul = 2
	while ans:
		if ll <= n <= ul:
			ans = False
		else:
			floor = floor + 1
			ll = ll + 1
			ul = ul + x
	print(floor)
t = int(input())
while t > 0:
	result()
	t = t - 1


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	q = 3
	c = 1
	while q <= a:
		q = q + b
		c = c + 1
	print(c)


def get_floor(x, n):
	cur_floor = 0
	max_flat_on_prev_floor = 0
	max_flat_on_floor = 0
	while True:
		cur_floor += 1
		if cur_floor == 1:
			max_flat_on_floor += 2
		else:
			max_flat_on_floor += x
		if max_flat_on_prev_floor <= n <= max_flat_on_floor:
			return cur_floor
		max_flat_on_prev_floor = max_flat_on_floor
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	print(get_floor(x, n))


t = int(input())
i = 0
j = 1
for testcase in range(t):
	inputs = list(map(int, input().split()))
	(n, x) = (inputs[i], inputs[j])
	if n <= 2:
		print(1)
	else:
		floor = (n - 3) // x + 2
		print(floor)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print('1')
		continue
	(s, c) = (2, 1)
	for i in range(2, 100000000):
		s = s + x
		c += 1
		if n <= s:
			print(c)
			break


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	print(max(math.ceil((n - 2) / x), 0) + 1)


import math
t = int(input())
for i in range(t):
	y = input().split()
	n = int(y[0])
	x = int(y[1])
	if n <= 2:
		print('1')
	else:
		n = n - 2
		count = int(math.ceil(n / x))
		print(count + 1)


def n_floor(n, x):
	if n == 1:
		return 1
	if x == 1:
		return n - 1
	if x == 2:
		return (n + 1) // 2
	f = n // x + 1
	if n % x > 2:
		f += 1
	return f
t = int(input())
for it in range(t):
	(n, x) = [int(tmp) for tmp in input().split()]
	print(n_floor(n, x))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		x = 2
		c = 1
		while 1:
			x += k
			c += 1
			if n <= x:
				break
		print(c)
	t -= 1


t = int(input())
n = []
x = []
for y in range(t):
	inp = [int(x) for x in input().strip().split()]
	n.append(inp[0])
	x.append(inp[1])
for y in range(t):
	(c, f) = (1, 1)
	while c > 0:
		c = n[y] - (f - 1) * x[y] - 2
		f = f + 1
	print(f - 1)


t = int(input())
for i in range(t):
	ch = input()
	n = int(ch.split()[0])
	x = int(ch.split()[1])
	n1 = 2
	x1 = 1
	while n1 < n:
		x1 += 1
		n1 += x
	print(x1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	floor = 1
	flag = True
	i = 1
	if n == 1 or n == 2:
		flag = False
		print(1)
	while flag:
		if n <= i * x + 2:
			print(i + 1)
			flag = False
			break
		i += 1


for s in range(int(input())):
	(a, b) = map(int, input().split())
	print((a - 3 + b) // b + 1 if a > 2 else 1)


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	start = 2
	cnt = 1
	while True:
		if n <= start:
			print(cnt)
			break
		start += x
		cnt += 1


import sys
si = sys.stdin.readline
t = int(si())
while t:
	t -= 1
	(n, x) = [int(e) for e in si().split()]
	if n <= 2:
		print(1)
	else:
		q = (n - 2) // x
		r = (n - 2) % x
		if r:
			print(q + 1 + 1)
		else:
			print(q + 1)


t = int(input())
for i in range(t):
	(n, x) = [int(j) for j in input().split()]
	floor = 0
	if n == 1 or n == 2:
		floor = 1
	else:
		floor = 2 + (n - 3) // x
	print(floor)


for u in range(int(input())):
	(n, k) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		if n % k == 0:
			print(1 + n // k)
		else:
			print(2 + n // k)


from math import ceil
out = []
t = int(input())
for i in range(0, t):
	tmp = input().split(' ')
	n = int(tmp[0])
	x = int(tmp[1])
	if n < 3:
		out.append(1)
	else:
		out.append(ceil((n - 2) / x + 1))
print(*out, sep='\n')


for i in range(int(input())):
	list_ = list(map(int, input().split()))
	apartment = list_[0]
	per_floor = list_[1]
	if apartment < 3:
		print(1)
	else:
		x = apartment - 2
		rem = x % per_floor
		if rem == 0:
			y = int(x / per_floor)
		else:
			y = int(x / per_floor) + 1
		print(y + 1)


t = int(input())
while t > 0:
	(n, x) = [int(x) for x in input().split()]
	n = n - 2
	if n <= 0:
		print(1)
	elif n % x == 0:
		print(n // x + 1)
	else:
		print(n // x + 2)
	t = t - 1


import math

def do_calc(n, m):
	if n <= 2:
		return 1
	else:
		floor_number = math.ceil((n - 2) / m) + 1
		return floor_number
test_cases = int(input())
for i in range(test_cases):
	line = input()
	(n, m) = line.split(' ')
	n = int(n)
	m = int(m)
	result = do_calc(n, m)
	print(result)


test_case = int(input())
for case in range(test_case):
	(nth_apartments, num_apartments) = list(map(int, input().split()))
	if nth_apartments <= 2:
		print(1)
		continue
	else:
		floor = 1
		froms = 1
		to = 2
		while True:
			(froms, to) = (to + 1, to + num_apartments)
			floor += 1
			if to >= nth_apartments:
				print(floor)
				break


for k in range(int(input())):
	(a, b) = map(int, input().split())
	if a < 3:
		print(1)
	elif (a - 2) % b != 0:
		print((a - 2) // b + 2)
	else:
		print((a - 2) // b + 1)


def findPetya(n, x):
	arr = [1, 2]
	if n in arr:
		print(1)
	else:
		k = 0
		while n not in arr:
			for i in range(k * x + 3, (k + 1) * x + 3):
				arr.append(i)
			k += 1
		print(k + 1)
t = int(input())
for i in range(0, t):
	findPetya(*list(map(int, input().split())))


T = int(input())
nx = [[0, 0] for _ in range(T)]
for t in range(T):
	nx[t] = list(map(int, input().split()))
for (n, x) in nx:
	if n <= 2:
		print(1)
		continue
	n -= 2
	print(-(-n // x) + 1)


from functools import reduce
import collections
import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(delimiter=' '):
		return input().split(delimiter)

	@staticmethod
	def list_int(delimiter=' '):
		return list(map(int, input().split(delimiter)))

def main():
	t = Read.int()
	for _ in range(t):
		(n, x) = Read.list_int()
		if n < 3:
			print(1)
		elif (n - 2) % x == 0:
			print((n - 2) // x + 1)
		else:
			print((n - 2) // x + 2)
main()


a = input()
i = 0
t = int(a)
while i < t:
	(x, y) = input().split()
	b = int(x)
	c = int(y)
	i = i + 1
	if b <= 2:
		print(1)
	else:
		b = b - 2
		d = b / c
		if b % c != 0:
			d = d + 1
		d = d + 1
		e = int(d)
		print(e)


import math
for i in range(int(input())):
	(n, x) = map(int, input().split())
	c = 1
	if n == 1 or n == 2:
		print(1)
	else:
		n = n - 2
		if n % x == 0:
			c += n // x
		else:
			c += n // x + 1
		print(c)


t = int(input())
for i in range(t):
	l = [int(i) for i in input().split()]
	if l[0] > 2:
		removed_ap = l[0] - 2
		y = removed_ap // l[1] + 1
		if removed_ap % l[1] == 0:
			print(y)
		else:
			print(y + 1)
	else:
		print(1)


t = int(input())
for i in range(t):
	A = list(map(int, input().split()))
	n = A[0]
	x = A[1]
	if n == 1 or n == 2:
		print(1)
	elif (n - 2) % x == 0:
		print(1 + (n - 2) // x)
	else:
		print(2 + (n - 2) // x)


def solution(n, x):
	if n <= 2:
		return 1
	else:
		n -= 2
		ans = n // x
		if n % x == 0:
			return ans + 1
		else:
			return ans + 2
for t in range(int(input())):
	(n, x) = map(int, input().split())
	print(solution(n, x))


import sys
input = sys.stdin.readline
Q = int(input())
for _ in range(Q):
	(a, b) = map(int, input().split())
	if a <= 2:
		print(1)
	else:
		a -= 2
		print(1 + (a + b - 1) // b)


import sys
import re
import math
count = 0

def solve(a, b):
	if a == 1 or a == 2:
		return 1
	return math.ceil((a - 2) / b) + 1
for line in sys.stdin:
	if count == 0:
		count = 1
		continue
	group_match = re.match('([0-9]+) ([0-9]+)', line)
	(a, b) = [int(group_match[i]) for i in range(1, 3)]
	print(solve(a, b))


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	(n, x) = I()
	if n == 1 or n == 2:
		print(1)
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)


import math
for _ in range(int(input())):
	tmp = input().split(' ')
	a = int(tmp[0])
	b = int(tmp[1])
	if a <= 2:
		print('1')
	else:
		a -= 2
		print(math.ceil(a / b) + 1)


while True:
	try:
		t = eval(input())
		for i in range(t):
			(n, x) = map(int, input().split())
			t1 = 1
			t2 = 2
			if n <= 2:
				print(1)
			elif 3 <= n <= x + 2:
				print(2)
			else:
				while not t1 * x + 3 <= n <= t2 * x + 2:
					t1 += 1
					t2 += 1
				print(t2 + 1)
	except:
		break


def solve(n, x):
	if n <= 2:
		return 1
	if (n - 2) % x == 0:
		return (n - 2) // x + 1
	return (n - 2) // x + 2
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	print(solve(n, x))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	cnt = 1
	i = 0
	f = 2
	while True:
		if f >= n:
			break
		f = f + x
		cnt += 1
	print(cnt)


import math
a = int(input())

def abir():
	return map(int, input().split())
for i in range(a):
	b = list(abir())
	d = math.ceil(max(b[0] - 2, 0) / b[1])
	print(d + 1)


import math
cases = int(input())
for case in range(cases):
	line = input().split(' ')
	num = int(line[0])
	apf = int(line[1])
	if num in [1, 2]:
		print(1)
	else:
		print(math.ceil((num - 2) / apf + 1))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		ans = 1
		n -= 2
		ans += int(n / k)
		if n % k:
			ans += 1
		print(ans)
	t -= 1


print('\n'.join([str((lambda n, x: 1 if n <= 2 else (n - 3) // x + 2)(*map(int, input().split()))) for _ in range(int(input()))]))


for __ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		print((n - 3) // x + 2)


t = 1
t = int(input())
while t:
	t -= 1
	(n, x) = list(map(int, input().split()))
	floor = 1
	n -= 2
	while n > 0:
		floor += 1
		n -= x
	print(floor)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def ans(n, x):
	if n < 3:
		return 1
	floor_number = 1
	while True:
		if (floor_number - 1) * x + 3 <= n <= floor_number * x + 2:
			return floor_number + 1
		floor_number += 1
m = inp()
for i in range(m):
	(n, x) = invr()
	print(ans(n, x))


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		(n, x) = map(int, input().split())
		ans = 1
		if n <= 2:
			print(1)
			continue
		(s, t) = (3, x + 2)
		while True:
			if n >= s and n <= t:
				ans += 1
				break
			ans += 1
			(s, t) = (s + x, t + x)
		print(ans)
main()


def main():
	T = eval(input())
	for case in range(T):
		(n, x) = map(int, input().split())
		cnt = 1
		i = 2
		while i < n:
			cnt += 1
			i += x
		print(cnt)
main()


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	for _ in range(ii()):
		(n, x) = mi()
		if n <= 2:
			print(1)
			continue
		c = 2
		p = 2 + x
		while n > p:
			p += x
			c += 1
		print(c)

def __starting_point():
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
	solve()
__starting_point()


for _ in range(0, int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		for i in range(1, 10001):
			if x * i + 2 >= n:
				print(i + 1)
				break


from math import *
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 1 or a == 2:
		print(1)
	else:
		p = abs((a - 3) // b + 1)
		print(p + 1)


import math
inf = float('inf')
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = 1
	n -= 2
	while n > 0:
		ans += 1
		n -= k
	print(ans)


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	n -= 2
	a = math.ceil(n / x)
	print(a + 1)


import sys, math
input = lambda : sys.stdin.readline().rstrip()

def gcd(n, f):
	if n == 0 or f == 0:
		return max(n, f)
	if n > f:
		return gcd(n % f, f)
	else:
		return gcd(f % n, n)

def division_with_remainder_up(pp, ppp):
	return (pp + ppp - 1) // ppp
for i in range(int(input())):
	(n, k) = map(int, input().split())
	n -= 2
	if n <= 0:
		print(1)
	else:
		print(division_with_remainder_up(n, k) + 1)


import sys
input = sys.stdin.buffer.readline

def solution():
	(n, x) = map(int, input().split())
	n = max(0, n - 2)
	z = n // x
	if n % x != 0:
		z += 1
	print(z + 1)
t = int(input())
for _ in range(t):
	solution()


import os
import sys

def get_int():
	return int(input())

def get_ints():
	return map(int, input().split())

def get_float():
	return float(input())

def get_floats():
	return map(float, input().split())

def list_ints():
	return list(map(int, input().split()))

def list_floats():
	return list(map(float, input.split()))

def post(x):
	print(x, end=' ')
T = int(input())
for t in range(1, T + 1):
	(n, x) = get_ints()
	print(1 if n <= 2 else (n - 3) // x + 2)


t = int(float(input()))
while t:
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		res = n % x
		n = n // x
		if res:
			n += 1
		n += 1
		print(n)
	t -= 1


t = int(input())
while t > 0:
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print(1)
	else:
		i = 0
		j = 2
		while True:
			low = i * x + 3
			up = (i + 1) * x + 2
			if n >= low and n <= up:
				print(j)
				break
			else:
				j += 1
				i += 1
	t -= 1


from math import ceil
for _ in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	if n <= 2:
		print(1)
		continue
	print(str(1 + ceil((n - 2) / x)))


import sys
import os
from math import sqrt, log, log2, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial, ceil
from copy import copy, deepcopy
import bisect
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()
mint = lambda : map(int, inp().split())

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def solve():
	(n, x) = mint()
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		n /= x
		n = ceil(n)
		print(n + 1)
for _ in range(iinp()):
	solve()


t = int(input())
r = 0
while r < t:
	ans = 1
	s = 2
	(n, x) = input().split()
	x = int(x)
	n = int(n)
	while s < n:
		s = s + x
		ans = ans + 1
	print(ans)
	r = r + 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		i = 1
		floor = 1
		last = 2
		while True:
			floor += 1
			first = last + 1
			last = i * x + 2
			i += 1
			if first <= n <= last:
				print(floor)
				break


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print('1')
	else:
		i = 2
		for j in range(n):
			if 3 + (i - 2) * x <= n and n <= 2 + (i - 1) * x:
				print(i)
			i += 1


t = eval(input())
for i in range(0, t):
	(b, a) = map(int, input().split())
	ans = 1
	if b > 2:
		b = b - 2
		ans += b // a
		if b % a != 0:
			ans += 1
	print(ans)


import sys
k = 0
for line in sys.stdin:
	if k == 0:
		N = int(line)
	else:
		(a, b) = line.strip().split()
		n = int(a)
		m = int(b)
		if n <= 2:
			print('1')
		else:
			print(str((n - 3) // m + 2) + '\n')
	k += 1


for i in range(int(input())):
	(n, t) = [int(num) for num in input().split()]
	if n == 1 or n == 2:
		print(1)
		continue
	c = n - 2
	c = c // t
	if (n - 2) % t == 0:
		print(c + 1)
	else:
		print(c + 2)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		e = 1
		n -= 2
		if n % x == 0:
			e += n / x
		else:
			e += n / x
			e += 1
		print(int(e))
	t -= 1


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	x = int(l[1])
	if n == 1 or n == 2:
		print(1)
		continue
	z = (n - 3) // x
	print(z + 2)


import math
t = int(input())
while t > 0:
	(n, x) = [int(i) for i in input().split()]
	if n == 1 or n == 2:
		print(1)
	else:
		dow = (n - 3) / x + 2
		print(math.floor(dow))
	t -= 1


t = int(input())
for o in range(t):
	(n, x) = map(int, input().split())
	ans = 1
	i = 2
	while n > i:
		ans += 1
		i += x
	print(ans)


for __ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	ans = 1
	n -= 2
	num = x
	while n > 0:
		if num == x:
			ans += 1
			num = 0
		n -= 1
		num += 1
	print(ans)


sdadw = int(input())
for qwe in range(sdadw):
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	l = [1, 2]
	count = 1
	z = 3

	def createList(r1, r2):
		return [item for item in range(r1, r2)]
	if n == 1 or n == 2:
		print(1)
	else:
		while n not in l:
			l = createList(z, z + x)
			z = z + x
			count = count + 1
		print(count)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	floor = x + 2
	c = 1
	while floor <= n:
		floor += x
		c += 1
	if floor - n >= 1 and floor - n <= x - 1:
		print(c + 1)
	else:
		print(c)


test_cases = int(input())
for test in range(test_cases):
	(n, x) = list(map(int, input().split()))
	print(1 if n < 2 else (n - 3) // x + 2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
from math import ceil, floor, sqrt, pow
for _ in range(N()):
	(n, x) = RL()
	if n < 3:
		print(1)
	else:
		print(ceil((n - 2) / x) + 1)


def floo(n, x):
	if n <= 2:
		return 1
	else:
		return (2 * n - 5) // (2 * x) + 2
k = int(input())
for i in range(0, k):
	s = list(map(int, input().split()))
	print(floo(s[0], s[1]))


from math import ceil, floor

def solve():
	(n, x) = map(int, input().split())
	if 1 <= n <= 2:
		print(1)
	else:
		print(ceil((n - 2) / x) + 1)
	return

def main():
	T = int(input())
	for i in range(T):
		solve()
	return
main()


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	floor = 1
	current = 2
	if n <= 2:
		print('1')
	else:
		for j in range(2, n + 1, x):
			floor += 1
			current += x
			if n <= current:
				print(floor)
				break


from sys import stdin
input = lambda : stdin.readline().strip()
lin = lambda : list(map(int, input().split()))
iin = lambda : int(input())
main = lambda : map(int, input().split())
from math import ceil, sqrt, factorial, log
from collections import deque
from bisect import bisect_left

def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	while a % b != 0:
		(a, b) = (b, a % b)
	return b
mod = 998244353

def solve(we):
	(n, x) = main()
	t = 2
	if n <= 2:
		print(1)
	else:
		print(ceil((n - 2) / x + 1))
qwe = 1
qwe = int(input())
for _ in range(qwe):
	solve(_ + 1)


import sys
tests = int(sys.stdin.readline())
while tests > 0:
	line = sys.stdin.readline()
	line = line.split(' ')
	flatNumb = int(line[0])
	everyFloor = int(line[1])
	flatNumb -= 2
	hisFloor = 1
	while flatNumb > 0:
		flatNumb -= everyFloor
		hisFloor += 1
	tests -= 1
	print(hisFloor)


t = int(input(''))
while t > 0:
	(n, x) = [int(n) for n in input().split()]
	r = 2
	if n < 3:
		print(1)
	else:
		while True:
			if n > x * (r - 1) + 2:
				r += 1
			else:
				print(r)
				break
	t -= 1


from __future__ import division, print_function
from io import BytesIO, IOBase
import os, sys, math, heapq, copy
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import permutations, combinations, combinations_with_replacement
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 1000000007

def get_int():
	return int(sys.stdin.readline().strip())

def get_str():
	return sys.stdin.readline().strip()

def get_float():
	return float(sys.stdin.readline().strip())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def get_floats():
	return map(float, sys.stdin.readline().strip().split())

def list_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def list_strs():
	return list(map(str, sys.stdin.readline().strip().split()))

def list_floats():
	return list(map(float, sys.stdin.readline().strip().split()))
t = get_int()
for _ in range(t):
	(n, x) = get_ints()
	if n <= 2:
		print(1)
	else:
		n -= 2
		print(math.ceil(n / x) + 1)


my_value = []
for i in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	if a <= 2:
		my_value.append(1)
	else:
		my_value.append((a - 3) // b + 2)
for i in my_value:
	print(i)


t = int(input())
for h in range(t):
	sh = list(map(int, input().split()))
	n = sh[0]
	x = sh[1]
	if n == 1 or n == 2:
		print(1)
	else:
		n = n - 2
		if n / x == n // x:
			n = n / x
			n += 1
		else:
			n = n // x
			n += 2
		print(int(n))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		l = [[1, 2]]
		f = 2
		s = 3
		while True:
			l1 = list(range(s, s + x))
			if n in l1:
				print(f)
				break
			else:
				f += 1
				s = s + x


def cal(n, x):
	if n == 1 or n == 2:
		return 1
	res = 1
	(start, end) = (3, x + 2)
	while not start <= n <= end:
		(start, end) = (end + 1, end + x)
		res += 1
	return res + 1
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	print(cal(n, x))


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		count = 1
		sumf = 2
		while 1:
			if sumf >= n:
				break
			sumf += x
			count += 1
		print(count)


import math
for i in range(int(input())):
	(n, x) = [int(j) for j in input().split()]
	if n == 1 or n == 2:
		print(1)
	else:
		print(math.ceil((n - 2) / x) + 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	piso = 1
	if n > 2:
		while piso * x + 2 < n:
			piso += 1
		piso += 1
	print(piso)


import sys
input = sys.stdin.readline
n = int(input())
while n > 0:
	(a, b) = input().split()
	if int(a) == 1 or int(a) == 2:
		print(1)
	else:
		for i in range(0, 1000):
			if i * int(b) + 3 <= int(a) and int(a) <= (i + 1) * int(b) + 2:
				k = i
				break
		print(k + 2)
	n = n - 1


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	c = 1
	k = 2
	if n == 1 or n == 2:
		print(1)
	else:
		while k < n:
			k = k + x
			c = c + 1
		print(c)


t = int(input())
ans = []
for i in range(0, t):
	(n, x) = map(int, input().split())
	if n <= 2:
		ans.append(1)
	else:
		j = n - 2
		if j % x != 0:
			k = j // x + 2
		else:
			k = j // x + 1
		ans.append(k)
for i in ans:
	print(i)


from sys import stdin, stdout
n = int(stdin.readline())
for i in range(n):
	(x, y) = map(int, stdin.readline().split())
	if x == 1 or x == 2:
		stdout.write('1' + '\n')
		continue
	x -= 2
	k = x // y + 1
	if x % y != 0:
		k += 1
	stdout.write(str(k) + '\n')


import sys

def solve(n1, n2):
	n1 -= 2
	if n1 <= 0:
		return 1
	if n1 % n2 == 0:
		return n1 // n2 + 1
	else:
		return int(n1 / n2 + 1) + 1
for i in range(int(input())):
	(z1, z2) = list(map(int, input().split()))
	print(solve(z1, z2))


t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	stage = 2
	answer = 1
	while stage < n:
		stage += x
		answer += 1
	print(answer)


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
for _ in range(n):
	l = inlt()
	n = l[0]
	x = l[1]
	if n < 2:
		print(1)
	else:
		n -= 2
		print((n - 1) // x + 2)


PI = 3.141592653589793
INF = 999999999
MOD = 1000000007

def add(x, y):
	return (x + y) % MOD

def sub(x, y):
	return (x - y + MOD) % MOD

def mul(x, y):
	return x * y % MOD

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

def ii():
	return int(input())

def li():
	return [int(i) for i in input().split()]

def ls():
	return [i for i in input().split()]
for t in range(ii()):
	t += 1
	(n, x) = li()
	if n <= 2:
		print(1)
	else:
		n -= 2
		print((n + x - 1) // x + 1)


import sys
T = int(sys.stdin.readline())
for i in range(T):
	(n, x) = map(int, sys.stdin.readline().split())
	floors = []
	for j in range(1000):
		if j == 0:
			floors.append([1, 2])
			if n in floors[-1]:
				print(1)
				break
		else:
			floors.append([x + 1 for x in range(floors[-1][-1], j * x + 2)])
			if n in floors[-1]:
				print(floors.index(floors[-1]) + 1)
				break


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		kv = 3
		p = 1
		for i in range(2, 1500):
			if n >= kv and n <= x * p + 2:
				print(i)
				break
			kv = x * p + 3
			p += 1


import sys
input = sys.stdin.readline
N = int(input())
for _ in range(N):
	(A, B) = map(int, input().split())
	if A <= 2:
		print(1)
	elif (A - 2) % B >= 1:
		print((A - 2) // B + 2)
	else:
		print((A - 2) // B + 1)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	if x == 1:
		if n == 1:
			print(1)
		else:
			print(n - 1)
	else:
		ret = (n - 3) // x + 2
		print(ret)


t = int(input())
while t:
	t = t - 1
	(a, b) = map(int, input().split())
	if a < 2:
		print(1)
	else:
		k = a - 2
		if k % b == 0:
			print(int(k / b) + 1)
		else:
			print(int(k / b) + 2)


import math
itr = int(input())
for i in range(itr):
	info = input().split(' ')
	numf = int(info[0])
	perf = int(info[1])
	re = 1
	numf -= 2
	if numf > 0:
		re += math.ceil(numf / perf)
	print(re)


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
		continue
	l = 3
	r = l + x - 1
	f = 2
	while not (n >= l and r >= n):
		l += x
		r = l + x - 1
		f += 1
	print(f)


def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	for i in range(n):
		if i * x + 2 >= n:
			print(i + 1)
			break


t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().split(' '))
	if n == 1:
		print('1')
	if n == 2:
		print('1')
	if n > 2:
		p = n - 2
		q = int(p / x)
		if p % x != 0:
			print(q + 2)
		if p % x == 0:
			print(q + 1)


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	ans = 1
	x = 2
	if n <= 2:
		print(1)
	else:
		for i in range(n):
			if x >= n:
				print(i + 1)
				break
			x += k


import sys, threading
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def rl(type):
	return [type(w) for w in input().split()]

def reverse(arr):
	return arr[-1::-1]

def mod(a, m):
	return (a % m + m) % m

def check_prime(n):
	temp = int(math.sqrt(n) + 1)
	for i in range(2, temp):
		if n % i == 0:
			return False
	return True

def create_graph(n):
	graph = {}
	for _ in range(n):
		(x, y) = map(int, input().split())
		graph[x].append(y)
		graph[y].append(x)
	return graph

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		n -= 2
		floorNo = int(n / k) + (1 if n % k else 0)
		print(floorNo + 1 if n > 0 else 1)
sys.setrecursionlimit(10 ** 6)
threading.stack_size(10 ** 8)
t = threading.Thread(target=main)
t.start()
t.join()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a <= 2:
		print(1)
	else:
		a -= 2
		ans = 1
		if a % b != 0:
			ans = 2
		ans += a // b
		print(ans)


def f(n, x):
	if n <= 2:
		return 1
	res = (n - 2) // x + 2 - ((n - 2) % x == 0) * 1
	return res
t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	print(f(n, x))


for _ in range(int(input())):
	(petya, each) = input().split()
	(petya, each) = (int(petya), int(each))
	if petya == 1 or petya == 2:
		print(1)
	else:
		petya -= 2
		floor = 1
		while petya > 0:
			petya -= each
			floor += 1
		print(floor)


a = int(input())
for i in range(0, a):
	b = list(map(int, input().split()))
	n = b[0]
	e = b[1]
	c = 2
	l = 1
	while c < n:
		l = l + 1
		c = c + e
	print(l)


for i in range(int(input())):
	(n, x) = map(int, input().split(' '))
	if n <= 2:
		print(1)
	else:
		f = 2
		st = 3
		while True:
			if n >= st and n <= st + x - 1:
				print(f)
				break
			f += 1
			st = st + x


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	p = v = 0
	if a <= 2:
		print(1)
	else:
		a -= 2
		f = math.ceil(a / b)
		print(f + 1)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	z = [[1, 2]]
	i = 2
	f = 1
	if n == 1 or n == 2:
		print(1)
	else:
		while i <= n:
			i += x
			f += 1
			if i >= n:
				print(f)
				break


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 and x == 1:
		print('1')
		continue
	if (n - 2) / x == (n - 2) // x:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n = n - 2
		c = 1
		if n % x == 0:
			c = c + n // x
		else:
			c = c + n // x + 1
		print(c)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	cnt = 0
	if a <= 2:
		print(1)
		continue
	else:
		a -= 2
		cnt += 1
	if a % b == 0:
		cnt += a // b
	else:
		cnt += a // b + 1
	print(cnt)


testcase = int(input())
for test in range(testcase):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		n = n - 2
		fl = n // x
		if n % x != 0:
			fl += 1
		fl += 1
		print(fl)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	l = 1
	r = 2
	cnt = 1
	while True:
		if l <= n <= r:
			print(cnt)
			break
		else:
			cnt += 1
			l = r + 1
			r += x


import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
q = I()
import math
for _ in range(q):
	(n, x) = readInts()
	if n <= 2:
		print(1)
		continue
	if x == 1:
		print(n - 1)
		continue
	n -= 2
	ans = 1
	ans += int(math.ceil(n / x))
	print(ans)


import os
import sys
from io import BytesIO, IOBase

def solution(n, x):
	cur = 3
	if n < 3:
		write(1)
		return
	res = 2
	while cur + x <= n:
		cur += x
		res += 1
	write(res)

def main():
	for _ in range(r_int()):
		(n, x) = r_array()
		solution(n, x)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


import math
rifat = int(input())
while rifat:
	a = [int(x) for x in input().split()]
	a[0] -= 2
	a[0] = max(a[0], 0)
	ans = math.ceil(a[0] / a[1]) + 1
	print(ans)
	rifat -= 1


from sys import stdin, stdout
from collections import deque
import bisect
import math
R = lambda : stdin.readline().strip()
RL = lambda f=None: list(map(f, R().split(' '))) if f else list(R().split(' '))
output = lambda x: stdout.write(str(x) + '\n')
output_list = lambda x: output(' '.join(map(str, x)))
T = int(input())
for _ in range(T):
	(n, x) = RL(int)
	if n <= 2:
		print(1)
		continue
	n -= 2
	print(math.ceil(n / x) + 1)


from math import ceil
num = int(input())
test = []
for i in range(num):
	test.append(input().split())
for j in test:
	x = int(j[1])
	n = int(j[0])
	if n < 2:
		print(1)
	else:
		n -= 2
		print(ceil(n / x) + 1)


t = int(input())
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	l = int((n - 3) / x)
	if n == 1 or n == 2:
		print('1')
	else:
		print(l + 2)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	f = 1
	a = 2
	while a < n:
		a += x
		f += 1
	print(f)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
total_input = read_int()
for i in range(total_input):
	(apartment, floor) = read_ints()
	if apartment <= 2:
		print(1)
	else:
		apartment -= 2
		print((apartment - 1) // floor + 2)


t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().split(' '))
	if n <= 2:
		print(1)
		continue
	n -= 2
	floor = 1
	floor += n // x
	n = n % x
	if n != 0:
		floor += 1
	print(floor)


from sys import stdin, stdout, setrecursionlimit
import threading

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			(n, x) = [int(x) for x in R().split()]
			if n <= 2:
				ans.append('1')
				continue
			floor = 2
			cnt = 1
			while floor < n:
				floor += x
				cnt += 1
			ans.append(str(cnt))
		W('\n'.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


from sys import stdin, stdout
from math import gcd, log2, log10, floor, ceil, sqrt
import math
from collections import defaultdict, OrderedDict
from bisect import bisect_left
for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print(1 + ceil((n - 2) / x))


import os
import math
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = inp()
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	(n, x) = invr()
	if n <= 2:
		print(1)
	else:
		print(math.ceil((n - 2) / x) + 1)


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		floor = n - 2
		print(math.ceil(floor / x) + 1)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	n = a[0]
	k = a[1]
	c = 2
	if n <= 2:
		print('1')
		continue
	i = 1
	while True:
		c += k
		if c >= n:
			print(i + 1)
			break
		i += 1


from sys import stdin, stdout
import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	n -= 2
	val = math.ceil(n / x)
	print(val + 1)


import sys
import os
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def floor_number(n, x):
	if n <= 2:
		print(1)
	else:
		print(math.ceil((n - 2) / x) + 1)
testcases = inp()
while testcases > 0:
	int_list = inlt()
	floor_number(int_list[0], int_list[1])
	testcases -= 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if 1 <= n <= 2:
		print(1)
		continue
	now = 2
	for s in range(3, 9999, x):
		if s <= n < s + x:
			print(now)
			break
		now += 1


n = int(input())
for i in range(n):
	(flat_n, x) = [int(i) for i in input().split()]
	if flat_n < 3:
		print(1)
	elif (flat_n - 2) % x == 0:
		print((flat_n - 2) // x + 1)
	else:
		print((flat_n - 2) // x + 2)


t = int(input())
t1 = t
ars = []
while t != 0:
	t -= 1
	l = 3
	f = z = 1
	(n, x) = map(int, input().split())
	restart = True
	while restart:
		for i in range(f, l):
			if i == n:
				ars.append(z)
				restart = False
				break
		if i != n:
			z += 1
			f = l
			l = (z - 1) * x + 3
for i in range(0, t1):
	print(ars[i])


tests = int(input())
for i in range(tests):
	(apt, num) = input().split()
	(apt, num) = (int(apt), int(num))
	cont = 3
	floor = 2
	if apt == 1 or apt == 2:
		print(1)
	else:
		while True:
			x = 0
			for j in range(num):
				if apt == cont:
					print(floor)
					x = 1
					break
				else:
					cont += 1
			floor += 1
			if x == 1:
				break


def process():
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print(1)
		return
	else:
		res = (n - 2 + x) / x
		if res % 1 != 0:
			res += 1
		print(int(res))
		return

def main():
	for i in range(int(input())):
		process()
main()


import sys
line = sys.stdin.readline()
t = int(line)
if t > 0:
	for i in range(0, t):
		line = sys.stdin.readline()
		s = line.split()
		n = int(s[0])
		x = int(s[1])
		if n <= 2:
			e = 1
		else:
			e = (n - 2 + x - 1) // x + 1
		print(str(e))


import math
T = int(input())
for test in range(T):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	elif 3 <= n <= x + 2:
		print(2)
	else:
		print(math.ceil((n - (x + 2)) / x) + 2)


def readis():
	return map(int, input().strip().split())
T = int(input())
while T:
	T -= 1
	(n, x) = readis()
	if n < 3:
		print(1)
	else:
		print((n - 3) // x + 2)


import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split(' '))
	c = 0
	if n <= 2:
		print('1')
	else:
		print(math.ceil((n - 2) / x) + 1)


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	if max(0, n - 2) % k != 0:
		print(max(0, n - 2) // k + 2)
	else:
		print(max(0, n - 2) // k + 1)


for _ in range(int(input().strip())):
	(n, x) = input().strip().split()
	n = int(n)
	x = int(x)
	if n <= 2:
		print('1')
	else:
		u = n - 2
		if u % x:
			print(u // x + 2)
		else:
			print(u // x + 1)


from sys import stdin, stdout
for _ in range(int(stdin.readline().strip())):
	(n, x) = map(int, stdin.readline().strip().split())
	if n <= 2:
		print(1)
	else:
		floor = 1
		num = 2
		c = True
		while c:
			num += x
			floor += 1
			if num >= n:
				break
		print(floor)


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	if x < 3:
		print(1)
	else:
		x -= 2
		if x % y > 0:
			c = 1
		else:
			c = 0
		a = x // y
		print(a + 1 + c)


for _ in ' ' * int(input()):
	(n, m) = map(int, input().split())
	n -= 2
	if n < 1:
		print(1)
	elif n % m == 0:
		print(n // m + 1)
	else:
		print(n // m + 2)


t = int(input())
for i in range(t):
	res = 2
	c = 1
	(a, b) = list(map(int, input().split()))
	if a == 1:
		print('1')
	else:
		for j in range(2, a, b):
			res += b
			c += 1
		print(c)
		c = 0


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	if n <= 2:
		print(1)
	else:
		n -= 2
		if n % k:
			ss = n // k + 1
		else:
			ss = n // k
		print(ss + 1)


def calc(n, x):
	if n < 3:
		return 1
	pos = (n - 3) % x
	return (n - (pos + 3)) // x + 2
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	print(calc(n, x))


t = int(input())
for _ in range(t):
	(n, h) = map(int, input().split())
	f = 0
	if n == 1 or n == 2:
		f = 0
	elif (n - 2) % h == 0:
		f = (n - 2) // h
	else:
		f = (n - 2) // h + 1
	print(f + 1)


t = int(input())
results = list()
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	f = 1
	f2 = 2
	s = 2
	c = 0
	if n == 1 or n == 2:
		results.append(f)
	else:
		while True:
			s += 1
			c += 1
			if c - 1 == x:
				f2 += 1
				c = 1
			if s == n:
				results.append(f2)
				break
for j in range(len(results)):
	print(results[j])


import math

def floorNumber(n, x):
	if n <= 2:
		return 1
	res = math.ceil((n - 2) / x)
	return res + 1
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	print(floorNumber(n, x))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var, end='\n'):
	sys.stdout.write(str(var) + end)

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, x) = sp()
	if n <= 2:
		out(1)
		continue
	answer = 1 + (n - 2) // x + (0, 1)[(n - 2) % x != 0]
	out(answer)


from math import *
from cmath import *
from decimal import *
from fractions import *
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print(1 + (n - 2) // x + int((n - 2) % x != 0))


for s in [*open(0)][1:]:
	(n, x) = map(int, s.split())
	print(max((n + x - 3) // x, 0) + 1)


t = int(input())
for tt in range(t):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		n = n - 2
		if n % x == 0:
			print(1 + n // x)
		else:
			print(2 + n // x)


import sys
import math
from functools import reduce
import bisect

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def input():
	return sys.stdin.readline().rstrip()

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return False
for _ in range(int(input())):
	(n, x) = getNM()
	if n < 3:
		print(1)
		continue
	print((n - 2) // x + (1 if (n - 2) % x else 0) + 1)


a = int(input())
for i in range(a):
	(n, x) = map(int, input().split())
	if n == 1:
		n = 2
	print(-1 * (-1 * (n - 2) // x) + 1)


import math
case = int(input())
for _ in range(case):
	(num, floors) = map(int, input().split(' '))
	if num <= 2:
		print(1)
	else:
		num -= 2
		print(math.ceil(num / floors) + 1)


t = int(input())
sum = 2
c = 0
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	if sum > n:
		print(c + 1)
	else:
		while sum < n:
			sum = sum + x
			c = c + 1
		print(c + 1)
		c = 0
		sum = 2


import sys
import math
t = int(input())
while t:
	(n, x) = map(int, input().split())
	ans = 1
	if n > 2:
		ans += math.ceil((n - 2) / x)
	print(ans)
	t -= 1


import math

def get_int():
	return int(input())

def get_ints():
	return [int(i) for i in input().split()]
for t in range(0, get_int()):
	(n, x) = get_ints()
	if n <= 2:
		print(1)
	else:
		n -= 2
		print((n - 1) // x + 2)


m = int(input())
l = []
for i in range(m):
	(a, b) = map(int, input().split())
	f = 2
	t = 1
	if a == 1 or a == 2:
		l.append(1)
	else:
		while True:
			if a <= f:
				l.append(t)
				break
			f += b
			t += 1
for i in l:
	print(i)


import math

def floor_number():
	test_cases = int(input())
	output = ''
	for t in range(test_cases):
		(n, x) = [int(x) for x in input().split(' ')]
		n = n - 2
		if n <= 0:
			print(1)
		else:
			print(1 + math.ceil(n / x))
floor_number()


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ans = 1
	s = 2
	while s < n:
		s += x
		ans += 1
	print(ans)


from math import floor
outs = []
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	out = 1
	n -= 2
	if n > 0:
		out = floor((n - 0.1) / x) + 2
	outs.append(out)
for out in outs:
	print(out)


a = int(input())
for i in range(0, a):
	(b, c) = map(int, input().split())
	ans = 1
	if b == 1:
		print('1')
	else:
		if (b - 2) % c == 0:
			ans += (b - 2) // c
		else:
			ans += (b - 2) // c + 1
		print(ans)


test = int(input())
for i in range(test):
	counter = 0
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	apartments = [2]
	while True:
		apartments.append(x + apartments[counter])
		if n == 1:
			print(1)
			apartments.clear()
			break
		elif n == 2:
			print(1)
			apartments.clear()
			break
		elif n <= apartments[counter]:
			print(counter + 1)
			apartments.clear()
			break
		counter += 1


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	(n, x) = idata()
	if n < 3:
		print(1)
	else:
		print(1 + (n - 3 + x) // x)
	return
for t in range(int(ii())):
	solve()


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 3
		print(2 + n // x)


t = int(input())
for i in range(t):
	(n, x) = [int(i) for i in input().split()]
	if n <= 2:
		print(1)
	else:
		k = 0
		while 1:
			if x * k + 3 <= n <= x * k + x + 2:
				break
				k += 1
			else:
				k += 1
		print(k + 2)


import math
total = []
num = int(input())
for x in range(num):
	(n, x) = [int(x) for x in input().split()]
	if n == 1 and x == 1:
		total.append(1)
	else:
		total.append(math.ceil((n - 2) / x) + 1)
for a in total:
	print(a)


t = int(input())
for x in range(t):
	a = input().split()
	b = int(a[0])
	a = int(a[1])
	if b <= 2:
		print(1)
	elif (b - 2) % a == 0:
		print((b - 2) // a + 1)
	else:
		print((b - 2) // a + 2)


for case in range(int(input())):
	(n, x) = [int(a) for a in input().split()]
	if n <= 2:
		print(1)
	else:
		ans = 1
		n -= 2
		rem = n % x
		if rem == 0:
			ans += n // x
		else:
			ans += n // x + 1
		print(ans)


for i in ' ' * int(input()):
	(n, x) = map(int, input().split())
	nn = n
	n -= 3
	if nn < 3:
		print(1)
		continue
	q = n // x
	print(q + 2)


t = int(input())

def main(n, x):
	if n <= 2:
		return 1
	else:
		return (n - 3) // x + 2
l = []
for i in range(t):
	b = input()
	if b == '':
		continue
	l += [main(int(b.split()[0]), int(b.split()[1]))]
for x in l:
	print(x)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		s = 2
		for i in range(2, 100000):
			s += x
			if s >= n:
				break
		print(i)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		n = n - 2
		i = 1
		while n > 0:
			n -= m
			i += 1
		print(i)


tn = int(input())
for _ in range(tn):
	(n, x) = list(map(int, input().split()))
	if n == 1 or n == 2:
		print(1)
		continue
	n = n - 2
	aprt = 1
	if n % x > 0:
		aprt = 2
	print(aprt + n // x)


import math
ansl = []
x = int(input())
for i in range(x):
	(y, z) = map(int, input().split())
	if y > 1:
		ansl.append(math.ceil((y - 2) / z) + 1)
	else:
		ansl.append(1)
for i in ansl:
	print(i)


m = int(input())
while m != 0:
	m -= 1
	inp = input()
	(n, x) = inp.split()
	n = int(n)
	x = int(x)
	if n < 2:
		a = 1
	else:
		a = (n - 3) // x + 2
	print(a)


import math

def read_int() -> int:
	return int(input())

def read_ints():
	return map(int, input().split(' '))

def test_case():
	(Petya_number, each_floor) = read_ints()
	floor_number = math.ceil((Petya_number - 2) / each_floor)
	if floor_number < 0:
		print(1)
	else:
		print(floor_number + 1)
tests = read_int()
for _ in range(tests):
	test_case()


import math

def solve(s):
	(apart_num, x) = [int(i) for i in s.strip().split()]
	if apart_num == 1 or apart_num == 2:
		print(1)
	else:
		print(math.ceil((apart_num - 2) / x) + 1)
num_tests = int(input())
for _ in range(num_tests):
	solve(input())


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
import math
for _ in range(ii()):
	(n, x) = f()
	if n == 1 or n == 2:
		print(1)
	else:
		a = n - 2
		print(math.ceil(a / x) + 1)


from sys import stdin
from math import ceil
n = int(stdin.readline())
for _ in range(n):
	(a, b) = map(int, stdin.readline().split())
	if a <= 2:
		print(1)
	else:
		weight = a - 2
		print(ceil(weight / b) + 1)


import sys
import math
import heapq
YES = 'YES'
NO = 'NO'
modulo = 10 ** 9 + 7

def solve():
	(n, x) = map(int, input().split())
	dp = [2]
	counter = 1
	while dp[-1] < n:
		dp.append(dp[-1] + x)
		counter += 1
	return counter
for _ in range(int(input())):
	print(solve())


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print(max(0, n - 2 + x - 1) // x + 1)


from math import ceil

def read_int() -> int:
	return int(input())

def read_ints():
	return map(int, input().split(' '))

def test_case():
	(n, x) = read_ints()
	print(1 if 1 <= n <= 2 else 1 + ceil((n - 2) / x))
for _ in range(read_int()):
	test_case()


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	(n, x) = map(int, stdin.readline().split())
	n -= 2
	ans = 1
	while n > 0:
		n -= x
		ans += 1
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		p = n - 2
		c = p // x
		if p % x != 0:
			c += 1
		print(1 + c)


import sys
import itertools

def get_line():
	return list(map(int, sys.stdin.readline().strip().split()))

def in1():
	return int(input())
for _ in range(in1()):
	(n, x) = get_line()
	t1 = 1
	t2 = 2
	c = 1
	while n > t1 and n > t2:
		t1 = t2 + 1
		t2 = c * x + 2
		c += 1
	print(c)


t = int(input())
while t:
	array = list(map(int, input().split()))
	n = array[0]
	x = array[1]
	floor = 1
	start = 1
	end = 2
	if (start < n or start == n) and (end == n or end > n):
		print(floor)
	else:
		while True:
			floor += 1
			start = end + 1
			end = start + x - 1
			if (start < n or start == n) and (end == n or end > n):
				print(floor)
				break
	t -= 1


t = int(input())
while t > 0:
	t -= 1
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print(1)
	else:
		cnt = 1
		for (i, j) in zip(range(3, n + x, x), range(2 + x, n + x, x)):
			if n in range(i, j + 1):
				print(cnt + 1)
			else:
				cnt += 1


import sys
t = int(input())
while t > 0:
	t -= 1
	input = sys.stdin.readline()
	(n, x) = map(int, input.split())
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		print((n - 1) // x + 2)


n = int(input())
lst = []
for i in range(n):
	x = input().split()
	y = list(map(int, x))
	lst.append(y)
for i in range(n):
	n = int(lst[i][0])
	x = int(lst[i][1])
	if n > x:
		t = (n - 2) / x
		if (n - 2) % x != 0:
			t = int(t) + 1
		print(int(t + 1))
	elif n <= 2:
		print('1')
	else:
		print('2')


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		count = 1
		while n > 0:
			n -= x
			count += 1
		print(count)


import math
a = int(input())
apart = list()
for j in range(a):
	apart.append(list(map(int, input().split())))
for j in range(a):
	apart[j][0] = apart[j][0] - 2
	if apart[j][0] <= 0:
		print('1')
	else:
		number = math.ceil(apart[j][0] / apart[j][1]) + 1
		print(number)


import sys, math
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	(n, x) = inpl()
	if n <= 2:
		print(1)
	else:
		n -= 3
		print(n // x + 2)


import math
t = int(input())
L = []
for i in range(t):
	(n, x) = map(int, input().split())
	g = n - 2
	if n == 1:
		L.append(1)
	elif n == 2:
		L.append(1)
	elif g % x == 0:
		c = g // x
		c = c + 1
		L.append(c)
	elif g == 1:
		L.append(2)
	elif g > x:
		c = g // x
		k = c + 2
		L.append(k)
	elif g == x:
		L.append(2)
	elif x > n:
		L.append(2)
	else:
		L.append(2)
for x in range(len(L)):
	print(L[x], sep='\n')


t = int(input())

def search_floor():
	(n, x) = map(int, input().split())
	answer = 1
	if n == 1 or n == 2:
		return answer
	else:
		answer += (n - 2) // x
		if (n - 2) % x > 0:
			answer += 1
		return answer
answers = []
for i in range(t):
	answers.append(search_floor())
for i in answers:
	print(i)


inp = int(input())
for i in range(inp):
	count = 1
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	if n <= 2:
		print(1)
	else:
		n = n - 2
		s = n // x
		count += s
		if n % x > 0:
			count += 1
		print(count)


import math
t = int(input())
while t >= 1 and t <= 1000:
	list_1 = input().split(' ')
	n = int(list_1[0])
	x = int(list_1[1])
	t = t - 1
	if n == 1 or n == 2:
		floor_num = 1
		print(floor_num)
	elif n >= 3 and x <= 1000:
		floor_num = (n - 2) / x
		floor_num = math.ceil(floor_num)
		floor_num += 1
		print(floor_num)


import math
m = int(input())
for i in range(0, m):
	p = []
	p = list(map(int, input().split(' ')))
	if p[0] < 3:
		print(1)
	else:
		print(math.ceil((p[0] - 2) / p[1]) + 1)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	x -= 2
	if x > 0:
		if x % y == 0:
			print(x // y + 1)
		else:
			print(x // y + 2)
	else:
		print('1')


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	if n < 3:
		print(1)
		continue
	k = (n - 2) // x
	if (n - 2) % x == 0:
		print(k + 1)
	else:
		print(k + 2)


for _ in range(int(input())):
	(N, X) = [int(i) for i in input().split(' ')]
	if N <= 2:
		print(1)
	elif (N - 2) % X == 0:
		print((N - 2) // X + 1)
	else:
		print((N - 2) // X + 2)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
for _ in range(ii()):
	(n, x) = mi()
	if n <= 2:
		print(1)
	else:
		n -= 2
		sol = ceildiv(n, x)
		print(sol + 1)


n = int(input())
for i in range(n):
	(m, x) = [int(i) for i in input().split()]
	if m <= 2:
		print(1)
	elif (m - 2) % x:
		print(2 + (m - 2) // x)
	else:
		print(1 + (m - 2) // x)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	ans = 0
	if n > 0:
		ans += 1
		n = n - 2
	while n > 0:
		n = n - x
		ans += 1
	print(ans)


import sys
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		floor = 1
		p = x
		app = 2
		while app != n:
			for i in range(0, x):
				app += 1
				if app == n:
					break
			floor += 1
		print(floor)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import Counter, defaultdict, deque

def int1():
	return int(input())

def map1():
	return map(int, input().split())

def list1():
	return list(map(int, input().split()))
mod = pow(10, 9) + 7

def solve():
	(n, k) = map1()
	if n == 1 or n == 2:
		print(1)
	else:
		v = n - 2
		v = math.ceil(v / k)
		print(v + 1)
for _ in range(int(input())):
	solve()


import math
t = int(input())
results = []
for i in range(t):
	(n, x) = list(map(int, input().split(' ')))
	if n <= 2:
		results.append(1)
	else:
		results.append(math.ceil((n - 2) / int(x)) + 1)
for result in results:
	print(result)


t = int(input())
ans = []
for i in range(t):
	(n, x) = map(int, input().split())
	ans.append(max((n - 3) // x + 2, 1))
print(*ans, sep='\n')


for t in range(int(input())):
	(n, x) = map(int, input().split())
	floors = 1
	if n <= 2:
		pass
	else:
		n -= 2
		if str(n / x).split('.')[1] == '0':
			floors += n // x
		else:
			floors += n // x + 1
	print(floors)


from math import ceil, floor
for _ in range(int(input())):
	(s, d) = map(int, input().split())
	if s < 3:
		print(1)
	else:
		n = floor((s - 3) / d) + 2
		print(n)


f = int(input())
for q in range(f):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		print((n - 2) // x + int((n - 2) % x != 0) + 1)


t = int(input())
while t:
	t -= 1
	(m, n) = list(map(int, input().split(' ')))
	if m < 3:
		print(1)
	else:
		m = m - 2
		if m % n == 0:
			print(m // n + 1)
		else:
			print(m // n + 2)


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def solve():
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		this_f = 2
		floor_covered = 0
		while n:
			if this_f >= n:
				cout << floor_covered + 1 << endl
				break
			floor_covered += 1
			if this_f == 2:
				this_f = x + 2
			else:
				this_f = x * floor_covered + 2

def main():
	solve()
main()


t = int(input())
arr = []
for i in range(0, t):
	(n, x) = list(map(int, input().split()))
	z = (n - 2) // x
	if z < 0:
		z = 0
	tmp = 2 + z * x
	if tmp < n:
		arr.append(z + 2)
	else:
		arr.append(z + 1)
for k in arr:
	print(k)


def read_array():
	x = []
	x1 = []
	x = input()
	x = x.split(' ')
	for r in range(len(x)):
		x1.append(int(x[r]))
	return x1

def return_floor(n, x):
	if n <= 2:
		return 1
	elif (n - 2) % x == 0:
		return (n - 2) // x + 1
	else:
		return (n - 2) // x + 2
m = int(input())
res = []
for r in range(m):
	x = read_array()
	res.append(return_floor(x[0], x[1]))
for v in res:
	print(v)


import math
cases = int(input())
for i in range(cases):
	variables = input().split()
	n = int(variables[0])
	x = int(variables[1])
	if n == 1 or n == 2:
		print(1)
	else:
		a = n - 2
		print(math.ceil(a / x) + 1)


from math import ceil
t = int(input())
for T in range(t):
	(n, x) = [int(i) for i in input().split()]
	if n <= 2:
		print(1)
		continue
	n -= 2
	print(ceil(n / x) + 1)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n == x == 1:
		print(1)
	else:
		print((n - 3 + x) // x + 1)


import math
n1 = int(input())
for _ in range(n1):
	n2 = input()
	l = [int(item) for item in n2.split()]
	(n, x) = (l[0], l[1])
	if n <= 2:
		print(1)
	else:
		print(1 + math.ceil((n - 2) / x))


t = int(input())
for i in range(t):
	(n, k) = input().strip().split(' ')
	(n, k) = [int(n), int(k)]
	n -= 2
	if n <= 0:
		print(1)
	else:
		p = n // k
		if n % k:
			p += 1
		print(p + 1)


import os
import heapq
import sys, threading
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, x) = inpt()
		n -= 2
		if n < 0:
			n = 0
		ans = n // x + 1
		if n % x != 0:
			ans += 1
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	ans = (n - 2) / k
	if n < 3:
		print(1)
	else:
		print(int(ans) + 1 if ans - int(ans) == 0 else int(ans) + 2)


T = int(input())
for t in range(T):
	(n, x) = [int(i) for i in input().split(' ')]
	if n <= 2:
		print(1)
		continue
	n -= 2
	f = n // x
	if n % x == 0:
		print(f + 1)
	else:
		print(f + 2)


for _ in range(int(input())):
	(m, x) = map(int, input().split())
	m = m - 2
	o = 1
	while m > 0:
		o += 1
		m -= x
	print(o)


import math
for _ in range(int(input())):
	(N, x) = map(int, input().split())
	count = 1
	for i in range(2, N, x):
		count += 1
	print(count)


t = int(input())
for i in range(t):
	a = n = input().split()
	n = int(a[0])
	x = int(a[1])
	if n <= 2:
		print(1)
		continue
	if n > 2 and (n - 2) % x == 0:
		print((n - 2) // x + 1)
		continue
	print((n - 2) // x + 2)


from sys import stdin
input = stdin.readline
from collections import defaultdict

def solve():
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		return
	else:
		n -= 3
		print(n // x + 2)
		return
t = int(input())
for _ in range(t):
	solve()


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n < 3:
		print(1)
		continue
	r = 1 + math.ceil((n - 2) / k)
	print(r)


import math

def main():
	t = int(input())
	for i in range(t):
		(n, x) = [int(i) for i in input().split()]
		if n <= 2:
			print(1)
		else:
			f = math.ceil((n - 2) / x) + 1
			print(f)
main()


def floor(n, x):
	ans = -1
	res = 2
	for i in range(n):
		if res >= n:
			ans = i + 1
			break
		else:
			res += x
	print(ans)
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	floor(n, x)


for i in range(int(input())):
	n = list(map(int, input().split()))
	a = n[0] - 2
	if a <= 0:
		print(1)
	else:
		b = a // n[1]
		if a % n[1] == 0:
			print(b + 1)
		else:
			print(b + 2)


for m in range(int(input())):
	nx = list(map(int, input().split()))
	if nx[0] > 2:
		if (nx[0] - 2) % nx[1] > 0:
			print(1 + (nx[0] - 2) // nx[1] + 1)
		else:
			print(1 + (nx[0] - 2) // nx[1])
	else:
		print(1)


t = int(input())
for test in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	if (n - 2) % x == 0:
		print((n - 2) // x + 1)
		continue
	floor = (n - 2) // x + 2
	print(floor)


from math import floor, log2
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	res = 1
	if n <= 2:
		res = 1
	else:
		n -= 2
		res += n // x
		if n % x != 0:
			res += 1
	print(res)


for i in range(int(input())):
	(nomer, kolvo) = map(int, input().split())
	print(1 if nomer <= 2 else (nomer - 3) // kolvo + 2)


t = int(input())
a = []
for i in range(t):
	(n, x) = [int(i) for i in input().split()]
	if n > 2 and (n - 2) % x == 0:
		a.append((n - 2) // x + 1)
	elif n == 1 or n == 2:
		a.append(1)
	elif n > 2 and (n - 2) % x != 0:
		a.append((n - 2) // x + 2)
for i in a:
	print(i)


casos = int(input())
for i in range(casos):
	(n, x) = [int(x) for x in input().split()]
	respuesta = (n - 3) // x + 2
	if n <= 2:
		respuesta = 1
	print(respuesta)


a = int(input())
b = 0
while True:
	(x, y) = input().split()
	xx = int(x)
	yy = int(y)
	if xx <= 2:
		print(1)
	elif (xx - 2) % yy == 0:
		print((xx - 2) // yy + 1)
	else:
		print((xx - 2) // yy + 2)
	b += 1
	if a == b:
		break


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print('1')
	else:
		ans = math.floor((n - 3) / x + 2)
		print(ans)


t = int(input())

def solve():
	(n, x) = map(int, input().split())
	start = 1
	stop = 2
	floor = 1
	while True:
		if n >= start and n <= stop:
			print(floor)
			break
		else:
			start = stop + 1
			stop = start + x - 1
			floor += 1
for i in range(t):
	solve()


for t in range(int(input())):
	(n, x) = [int(k) for k in input().split()]
	n -= 2
	ans = 1
	if n <= 0:
		print(1)
		continue
	if n % x == 0:
		ans += n // x
	else:
		ans += 1
		ans += n // x
	print(ans)


from math import *
from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	(n, k) = M()
	if n <= 2:
		print(1)
	else:
		n -= 2
		ans = ceil(n / k)
		print(ans + 1)


from collections import defaultdict
floor_apart = defaultdict(list)
floor_apart[1].append([1, 2])

def find_floor(n, x):
	apart_count_begin = 3
	a = 1
	apart_count_end = a * x + 2
	floor_num = 1
	next_fno = 3
	while next_fno < n:
		for i in range(apart_count_begin, apart_count_end + 1):
			floor_apart[floor_num + 1].append(i)
		next_fno = floor_apart[floor_num + 1][-1]
		floor_num = floor_num + 1
		apart_count_begin = apart_count_end + 1
		a = a + 1
		apart_count_end = a * x + 2
	if n == 3:
		return floor_num + 1
	return floor_num
test = int(input())
floors = []
for i in range(test):
	(n, x) = [int(i) for i in input().split()]
	floor_no = find_floor(n, x)
	floors.append(floor_no)
for i in floors:
	print(i)


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l
mod = int(1000000000.0) + 7

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(a):
	print(a)

def p2(a, b):
	print(a, b)
for _ in range(iinp()):
	(n, x) = ninp()
	n = n - 2
	f = 1
	while n > 0:
		n = n - x
		f += 1
	print(f)


T = int(input())
for t in range(T):
	(n, x) = list(map(int, list(input().split())))
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		i = 1
		while n > 0:
			i += 1
			n -= x
		print(i)


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	if n < 3:
		print(1)
		continue
	right = 3
	left = m + 2
	for i in range(1, n // m + 3):
		if right <= n <= left:
			print(i + 1)
			break
		right = i * m + 3
		left = (i + 1) * m + 2


import io, os, math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
rr = lambda : input()
rri = lambda : int(input())
rrm = lambda : list(map(int, input().split()))
INF = float('inf')

def solve(N, X):
	if N == 1 or N == 2:
		return 1
	(lo, hi) = (3, X + 2)
	floor = 2
	while True:
		if lo <= N <= hi:
			return floor
		floor += 1
		lo = hi + 1
		hi = lo + (X - 1)
	return -1
t = rri()
for _ in range(t):
	(N, X) = rrm()
	print(solve(N, X))


def function(n, x):
	if n == 1 or n == 2:
		return 1
	floor = 1
	house = 3
	while house <= n:
		house += x
		floor += 1
	return floor
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(function(a, b))


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}
from math import ceil

def solve(n, x):
	n -= 2
	cnt = 1
	while n > 0:
		n -= x
		cnt += 1
	return cnt
for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	print(solve(n, x))


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))
import math

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math as M
MOD = 10 ** 9 + 7
from random import randint as R
for _ in range(int(input())):
	(n, x) = INPUT()
	if n <= 2:
		print(1)
		continue
	print(int(M.ceil((n - 2) / x)) + 1)


import sys, math

def get_ints():
	return map(int, I().split())

def get_list():
	return list(map(int, I().split()))

def I():
	return sys.stdin.readline()
for i in range(int(I())):
	(n, x) = get_ints()
	if n < 3:
		print(1)
		continue
	n -= 2
	n = math.ceil(n / x)
	print(int(n + 1))


import heapq as hq
from heapq import heappop, heappush
from collections import deque, defaultdict, Counter
from sys import stdin, stdout

def inp():
	return int(stdin.readline())

def inlt():
	return list(map(int, stdin.readline().split()))

def insr():
	return list(stdin.readline().strip())

def invr():
	return map(int, stdin.readline().split())

def subset_sum_count(arr, n, sum):
	dp = [[0 for _ in range(sum + 1)] for _ in range(n + 1)]
	for i in range(n + 1):
		for j in range(sum + 1):
			if j == 0:
				dp[i][j] = 1
			elif arr[i - 1] <= j:
				dp[i][j] = dp[i - 1][j - arr[i - 1]] + dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j]
	return dp[n][sum]

def binary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		mi = lo + (hi - lo) / 2
		if func(mi):
			hi = mi
		else:
			lo = mi
	return (lo + hi) / 2

def ternary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		lo_third = lo + (hi - lo) / 3
		hi_third = hi - (hi - lo) / 3
		if func(lo_third) < func(hi_third):
			lo = lo_third
		else:
			hi = hi_third
	return (lo + hi) / 2

def discrete_binary_search(func, lo, hi):
	while lo < hi:
		mi = lo + (hi - lo) // 2
		if func(mi):
			hi = mi
		else:
			lo = mi + 1
	return lo

def discrete_ternary_search(func, lo, hi):
	while lo <= hi:
		lo_third = lo + (hi - lo) // 3
		hi_third = lo + (hi - lo) // 3 + (1 if 0 < hi - lo < 3 else (hi - lo) // 3)
		if func(lo_third) < func(hi_third):
			lo = lo_third + 1
		else:
			hi = hi_third - 1
	return lo
	return -1

def right_rotate(a, s):
	return a[s:] + a[:s]

def dec_to_bin(x):
	return int(bin(x)[2:])

def str_to_integer_list(n):
	a = []
	for i in range(len(n)):
		a.append(int(n[i]))
	return a

def list_to_str(l):
	s = ''
	for i in l:
		s += str(i)
	return s

def dijkstra(s, N, E):
	visited = set()
	dist = {}
	for i in range(1, N + 1):
		dist[i] = 1 << 29
	queue = [(dist[i], i) for i in range(1, N + 1)]
	hq.heappush(queue, (0, s))
	dist[s] = 0
	while queue:
		(d, u) = hq.heappop(queue)
		if u in visited:
			continue
		for t in E[u]:
			(v, r) = t
			if dist[v] > d + r:
				dist[v] = d + r
				hq.heappush(queue, (dist[v], v))
		visited.add(u)
	return dist

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def dijkstra(n, graph, start):
	(dist, parents) = ([float('inf')] * n, [-1] * n)
	dist[start] = 0
	queue = [(0, start)]
	while queue:
		(path_len, v) = heappop(queue)
		if path_len == dist[v]:
			for (w, edge_len) in graph[v]:
				if edge_len + path_len < dist[w]:
					(dist[w], parents[w]) = (edge_len + path_len, v)
					heappush(queue, (edge_len + path_len, w))
	return (dist, parents)

def path(start, end, parent):
	path = [end]
	while path[-1] != start:
		path.append(parent[path[-1]])
	path.reverse()
	return path

def bfs(graph, start, goal):
	if start == goal:
		return [start]
	visited = {start}
	queue = deque([(start, [])])
	while queue:
		(current, path) = queue.popleft()
		visited.add(current)
		for neighbor in graph[current]:
			if neighbor == goal:
				return path + [current, neighbor]
			if neighbor in visited:
				continue
			queue.append((neighbor, path + [current]))
			visited.add(neighbor)
	return None

def fillPrefixSum(arr, n, prefixSum):
	prefixSum[0] = arr[0]
	for i in range(1, n):
		prefixSum[i] = prefixSum[i - 1] + arr[i]

def check(a, ind, d1):
	beg = a[:ind + 1]
	end = a[ind + 1:]
	d = []
	c = 0
	for i in end:
		if i - d1 in beg:
			c += 1
	return c
import os
import sys
from io import BytesIO, IOBase

def DecimalToBinary(n):

	def helper(n):
		if n == 0:
			return ''
		else:
			if n % 2 == 1:
				binaryDigit = '1'
			else:
				binaryDigit = '0'
			return helper(n // 2) + binaryDigit
	if n == 0:
		result = '0'
	else:
		result = helper(n)
	return result

def p(board):
	for i in range(8):
		s = ''
		for j in range(8):
			s += board[i][j]
		print(s)

def binaryToDecimal(n):
	return int(n, 2)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def solve(a, b):
	x = DecimalToBinary(a)
	y = DecimalToBinary(b)
	z = x + y
	l = y + x
	r = binaryToDecimal(z) - binaryToDecimal(l)
	return r

def mostFrequent(arr, n):
	arr.sort()
	max_count = 1
	res = arr[0]
	curr_count = 1
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			curr_count += 1
		else:
			if curr_count > max_count:
				max_count = curr_count
				res = arr[i - 1]
			curr_count = 1
	if curr_count > max_count:
		max_count = curr_count
		res = arr[n - 1]
	return res
from bisect import bisect_right, bisect_left

def lds(arr, n):
	lds = [0] * n
	max = 0
	for i in range(n):
		lds[i] = 1
	for i in range(1, n):
		for j in range(i):
			if arr[i] < arr[j] and lds[i] < lds[j] + 1:
				lds[i] = lds[j] + 1
	for i in range(n):
		if max < lds[i]:
			max = lds[i]
	return max
import math

def prefix(a):
	pre = []
	pre.append(a[0])
	for i in range(1, len(a)):
		pre.append(pre[i - 1] + a[i])
	return pre

def solve(n, x, size):
	res = 10000000
	if n == 0:
		return 0
	if size == 0:
		return 0
	for i in x:
		res = 1 + min(res, solve(n - i, x, size - 1))
		return res

def main():
	for _ in range(inp()):
		(n, x) = invr()
		if n < 3:
			print(1)
		else:
			res = math.ceil((n - 2) / x) + 1
			print(int(res))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(num, xx) = map(int, input().split())
	if num == 1 or num == 2:
		print(1)
	else:
		ao = 1
		mmmm = 2
		while mmmm < num:
			mmmm += xx
			ao += 1
		print(ao)


from sys import stdin, stdout

def rem(a, b):
	y = b
	floor = 0
	if a < 3:
		return 1
	elif a > b:
		while a > b:
			if floor == 0:
				b = b + 2
			else:
				b = b + y
			floor += 1
		return floor + 1
	else:
		return 2

def main():
	n = 0
	for line in stdin:
		x = [int(i) for i in line.split()]
		if len(x) == 2:
			stdout.write(str(rem(x[0], x[1])) + '\n')
main()


T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	if N <= 2:
		ans = 1
	else:
		ans = (N - 2) // X + 1
		if (N - 2) % X != 0:
			ans += 1
	print(ans)


import math
t = int(input())
while t:
	a = input()
	(n, x) = [int(x) for x in a.split()]
	if n == 1 or n == 2:
		print(1)
		t -= 1
		continue
	k = math.ceil((n - 2) / x) + 1
	print(k)
	t -= 1


import math
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		a = (n + (x - 2)) / x
		sep = math.modf(a)
		if sep[0] == 0.0:
			print(int(a))
		else:
			print(int(a) + 1)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(n, x) = ria()
		for i in range(1, 1001):
			if (i - 1) * x + 2 >= n:
				print(i)
				break
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from sys import stdin, stdout, setrecursionlimit
import heapq
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, x) = iia()
	if n <= 2:
		print(1)
	else:
		n -= 2
		print(ceil(n / x) + 1)


[print(1 if int(s.split()[0]) < 3 else (int(s.split()[0]) - 3) // int(s.split()[1]) + 2) for s in [*open(0)][1:]]


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	e = 1
	k = 2
	while k < n:
		k += x
		e += 1
	print(e)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	res = 2
	ans = 1
	while n > res:
		ans += (n - res + (x - 1)) // x
		break
	print(ans)


t = int(input())

def solve(n, x):
	if n == 1 or n == 2:
		print(1)
		return
	level = 2
	(start, end) = (3, 3 + x - 1)
	while True:
		if start <= n <= end:
			print(level)
			return
		else:
			start = end + 1
			end = start + x - 1
			level += 1
for i in range(t):
	(n, x) = list(map(int, input().split()))
	solve(n, x)


try:
	for t in range(int(input())):
		(n, x) = map(int, input().split())
		k = 1
		if 1 <= n <= 2:
			print('1')
		else:
			i = 0
			j = 1
			c = 1
			while k != 0:
				c = c + 1
				a = i * x + 3
				b = j * x + 2
				if a <= n <= b:
					k = 0
					break
				i = i + 1
				j = j + 1
			print(c)
except:
	pass


for _ in range(int(input())):
	(n, x) = [int(p) for p in input().split()]
	if n <= 2:
		print(1)
		continue
	n -= 2
	print((n + x - 1) // x + 1)


import math
l = int(input(''))
l1 = []
for i in range(l):
	s = input('')
	(n, x) = s.split(' ')
	n = int(n)
	x = int(x)
	if n >= 1 and n <= 2:
		count = 1
	else:
		count = 1 + math.ceil((n - 2) / x)
	l1.append(count)
for i in l1:
	print(i, end='\n')


import sys, collections, math, itertools

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	(n, x) = get_ints()
	print(1 if n <= 2 else (n - 3) // x + 2)


t = int(input())
for tc in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		floor = 1
	else:
		n -= 2
		floor = 1
		if n % x != 0:
			floor += n // x + 1
		else:
			floor += n // x
	print(floor)


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	ans = ''
	for _ in range(ii()):
		(n, x) = mi()
		if n < 3:
			ans += '1\n'
		else:
			tmp = 3
			cnt = 2
			while 1:
				if n in range(tmp, x + tmp):
					break
				else:
					tmp += x
					cnt += 1
			ans += str(cnt) + '\n'
	print(ans)
main()


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	cur = 2
	notFound = True
	if n < 3:
		t -= 1
		print(1)
	else:
		while notFound:
			maxval = 2 + x * (cur - 1)
			if n <= maxval:
				notFound = False
				print(cur)
			else:
				cur += 1
		t -= 1


a = int(input())
for i in range(a):
	b = input().split()
	n = int(b[0])
	x = int(b[1])
	if n <= 2:
		floor = 1
	if n > 2:
		n_new = n - 2
		if n_new / x == float(n_new // x):
			floor = n_new // x + 1
		elif n_new / x > float(n_new // x):
			floor = n_new // x + 2
	print(floor)


c = int(input())
for i in range(c):
	d = input().split()
	n = d[0]
	x = d[1]
	a = 1
	b = 2
	while int(n) > b:
		b = a * int(x) + 2
		a += 1
	print(a)


import math
for item in range(int(input())):
	(n, x) = list(map(int, input().split()))
	if n == 1 or n == 2:
		print(1)
	elif n == 3:
		print(2)
	else:
		print(1 + math.ceil((n - 2) / x))


import math
from collections import deque
from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	(n, x) = list(map(int, input().strip().split(' ')))
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		print(math.ceil(n / x) + 1)


def main():
	(n, x) = map(int, input().split())
	(total, floor) = (2, 1)
	while n > total:
		total += x
		floor += 1
	print(floor)
for _ in range(int(input())):
	main()


t = int(input())
while t:
	(n, x) = map(int, input().split())
	temp = n
	if temp <= 2:
		f = 1
	else:
		temp = temp - 2
		r = temp % x
		q = int(temp / x)
		if r == 0:
			f = q + 1
		else:
			f = q + 2
	print(f)
	t = t - 1


import math
n = int(input())
data = []
for i in range(n):
	a = list(map(int, input().split()))
	data.append(a)
for i in data:
	total = i[0]
	x = i[1]
	if total <= 2:
		print(1)
	else:
		number = (total - 2) / x
		ans = math.ceil(number) + 1
		print(ans)


import math
t = int(input())
for i in range(t):
	inp = input().split(' ')
	(n, x) = (int(inp[0]), int(inp[1]))
	l = 1
	if n >= 2:
		l = math.ceil((n - 2) / x) + 1
	print(l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = 1
	n -= 2
	if n > 0:
		ans += n // k
		if n % k != 0:
			ans += 1
	print(ans)


def test():
	t = int(input())
	for i in range(t):
		(n, x) = input().split()
		(n, x) = (int(n), int(x))
		actual = 2
		floor = 1
		while actual < n:
			actual = x + actual
			floor += 1
		print(floor)
test()


import math

def main():
	t = int(input())
	for t_ in range(t):
		(n, x) = list(map(int, input().split()))
		if n < 3:
			print(1)
		else:
			print(math.ceil((n - 2) / x) + 1)
main()


n = int(input())
for num in range(n):
	param = list(map(int, input().split()))
	if param[0] <= 2:
		print(1)
	else:
		a = (param[0] - 2) / param[1]
		if int(a) == a:
			print(int(a) + 1)
		elif int(a) < a:
			print(int(a) + 2)


from collections import defaultdict
from sys import stdin
input = stdin.readline
from math import ceil

def put():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	(n, x) = put()
	if n <= 2:
		print(1)
	else:
		n -= 2
		ans = ceil(n / x)
		print(ans + 1)


from collections import defaultdict
import bisect
from math import ceil
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	c = 2
	ans = 0
	while n > 0:
		n -= c
		ans += 1
		c = x
	print(ans)


tst = int(input())
while tst > 0:
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print('1')
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)
	tst -= 1


import sys
from typing import List, Union

def rl(int_: bool=True, is_split: bool=True) -> Union[List[str], List[int]]:
	if int_:
		return [int(w) for w in sys.stdin.readline().split()]
	if is_split:
		return [w for w in sys.stdin.readline().split()]
	return sys.stdin.readline().strip()
for _ in range(rl()[0]):
	(n, x) = rl()
	if n < 3:
		print(1)
		continue
	print(2 + (n - 3) // x)


def floorr(n, noa):
	if n == 1 or n == 2:
		return 1
	else:
		start = 3
		end = 3 + noa - 1
		floor = 2
		while n > 0:
			if n >= start and n <= end:
				return floor
			start = end + 1
			end = start + noa - 1
			floor += 1
		return floor
n = int(input())
for i in range(n):
	x = input().split()
	print(floorr(int(x[0]), int(x[1])))


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, k) = R()
	if n <= 2:
		print(1)
	else:
		print((n - 2 + k - 1) // k + 1)


def main(n, x):
	from math import ceil
	if n in (1, 2):
		return 1
	return 1 + ceil((n - 2) / x)
t = int(input().strip())
for _ in range(t):
	(n, x) = map(int, input().strip().split())
	print(main(n, x))


import os
import sys

def get_int():
	return int(input())

def get_ints():
	return map(int, input().split())

def get_float():
	return float(input())

def get_floats():
	return map(float, input().split())

def list_ints():
	return list(map(int, input().split()))

def list_floats():
	return list(map(float, input.split()))

def post(x):
	print(x, end=' ')
T = int(input())
for t in range(1, T + 1):
	(n, x) = get_ints()
	res = 0
	if n <= 2:
		res = 1
	elif n in list(range(3, x + 3)):
		res = 2
	else:
		res = 3
		flag = 1
		up = 1
		y = 2
		while flag:
			if n not in list(range(up * x + 3, y * x + 3)):
				res += 1
				up += 1
				y += 1
			else:
				flag = 0
	print(res)


t = int(input())
for i in range(t):
	(y, x) = map(int, input().split())
	k = y - 2
	if y <= 2:
		print('1')
	elif int(k / x) * x == k:
		print(int(k / x) + 1)
	else:
		print(int(k / x) + 2)


import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 998244353

def f(n):
	s = int(sqrt(n))
	for i in range(s, s + 3):
		if i ** 2 == n:
			return s * 2 - 2
		a = s + 1
		b = s
		return a - 1 + b - 1

def main():
	ans = []
	for _ in range(int(input())):
		(n, x) = read()
		ans.append(str(max(0, ceil((n - 2) / x)) + 1))
	print('\n'.join(ans))
main()


import math
test_cases = int(input())
for _ in range(test_cases):
	floors = [int(x) for x in input().split()]
	petya = floors[0]
	apartments_per_floor = floors[1]
	check = 2
	counter = 1
	while petya > check:
		check += apartments_per_floor
		counter += 1
	print(counter)


from math import ceil

def checker(n, x):
	if n == 1 or n == 2:
		return 1
	else:
		return ceil((n - 2) / x) + 1
l = []
for t in range(int(input())):
	(n, x) = map(int, input().split())
	l.append(checker(n, x))
for result in l:
	print(result)


import math
for cases in range(int(input())):
	(total, x) = map(int, input().split())
	if total < 3:
		print(1)
	else:
		print(int(math.ceil((total - 2) / x)) + 1)


from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()
rli = lambda : map(int, stdin.readline().split())
rlf = lambda : map(float, stdin.readline().split())
(INF, NINF) = (float('inf'), float('-inf'))
MOD = 10 ** 9 + 7

def main():
	T = int(rl())
	for _ in range(T):
		(n, x) = rli()
		if n <= 2:
			print(1)
			continue
		for z in range(999999):
			(L, H) = (z * x + 3, (z + 1) * x + 2)
			if L <= n <= H:
				print(z + 2)
				break
	stdout.close()
main()


for i in '0' * int(input()):
	(n, x) = map(int, input().split())
	if n <= 2:
		print('1')
	else:
		print((n - 2) // x + min(1, (n - 2) % x) + 1)


from math import ceil
for tc in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		n -= 2
		ans = ceil(n / x) + 1
		print(ans)


import math
for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	if n < 3:
		y = 1
	else:
		n -= 2
		y = 1
		y += math.ceil(n / x)
	print(y)


def check_apartments(n, x):
	if n <= 2:
		return 1
	apa = x + 2
	if n <= apa:
		return 2
	floor = 2
	while apa < n:
		apa = floor * x + 2
		floor += 1
	return floor
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print(check_apartments(n, x))


import math
amit = int(input())
for _ in range(amit):
	(n, x) = [int(a) for a in input().strip().split()]
	if n < 3:
		print(1)
	else:
		print(int(math.ceil((n - 2) / x)) + 1)


from math import ceil
for q in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	n -= 2
	print(ceil(n / x) + 1)


import sys
import math
T = int(input())
userIn = []
res = []
for i in range(T):
	(n, x) = input().split()
	userIn.append([n, x])
for i in range(len(userIn)):
	curN = int(userIn[i][0])
	curX = int(userIn[i][1])
	if curN == 1 or curN == 2:
		res.append(1)
	elif curN == 3:
		res.append(2)
	else:
		floor = 2
		first = 3
		size = first + curX
		while True:
			nums = [i0 for i0 in range(first, size)]
			if curN in nums:
				res.append(floor)
				break
			else:
				first = first + curX
				size = first + curX
				floor += 1
for i in res:
	print(i)


def solve(n, x):
	count = 1
	if n <= 2:
		print(1)
		return
	while True:
		if n < 3 + count * x:
			break
		count = count + 1
	print(count + 1)
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	ans = solve(n, x)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	a -= 2
	a = max(0, a)
	c = 1
	c = c + int(a / b)
	if a % b:
		c += 1
	print(c)


t = int(input())
for i in range(t):
	(n, x) = [int(j) for j in input().split()]
	if n == 1 or n == 2:
		print(1)
	elif (n - 2) % x == 0:
		m = (n - 2) // x
		print(m + 1)
	else:
		m = (n - 2) // x
		print(m + 2)


t = int(input())
for i in range(t):
	nk = list(map(int, input().split()))
	n = nk[0]
	x = nk[1]
	flo = 0
	n = n - 2
	flo = 1
	while n > 0:
		n = n - x
		flo += 1
	print(flo)


def solve():
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		return
	prev = 2
	for i in range(1, 1001):
		if prev + 1 <= n <= i * x + 2:
			print(i + 1)
			return
t = int(input())
while t != 0:
	solve()
	t -= 1


def ans(n, x):
	if n <= 2:
		return 1
	return 1 + (n - 3 + x) // x
for i in range(int(input())):
	(n, x) = map(int, input().split())
	print(ans(n, x))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ans = 1
	ap = 2
	while ap < n:
		ap += x
		ans += 1
	else:
		print(ans)


tests = int(input())
for testnum in range(tests):
	[n, x] = list(map(int, input().split()))
	if n <= 2:
		print(1)
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		floor = 2
		while True:
			apartments = [(floor - 2) * x + 3, (floor - 1) * x + 2]
			if apartments[0] <= n and apartments[1] >= n:
				print(floor)
				break
			floor += 1


rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
yn = lambda x: print('Yes') if x else print('No')
for _ in range(rn()):
	(n, x) = rns()
	from math import ceil
	print(max(0, ceil((n - 2) / x)) + 1)


try:
	for _ in range(int(input())):
		(n, x) = list(map(int, input().split()))
		if n < 3:
			print(1)
			continue
		if int(n - 2) % x:
			print(int((n - 2) / x) + 2)
		else:
			print(int((n - 2) / x) + 1)
except:
	pass


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		f = 2
		start = 3
		end = x + 2
		while True:
			if n <= end:
				print(f)
				break
			else:
				start = end + 1
				end = f * x + 2
				f += 1


import math
lines = []
j = 1
no_of_lines = int(input())
while True:
	if no_of_lines >= j:
		line = input()
		lines.append(line)
		j += 1
	else:
		break
k = 0
while k < no_of_lines:
	lines[k] = str(lines[k]).split()
	k += 1
i = 0
while i < no_of_lines:
	if int(lines[i][0]) > 2:
		floated = (int(lines[i][0]) - 2) / int(lines[i][1])
		print(math.ceil(floated) + 1)
	else:
		print(1)
	i += 1


def string_split(s, a):
	output_list = []
	intermediate_str = ''
	for (loc, i) in enumerate(s):
		if i != a:
			intermediate_str += i
			if loc == len(s) - 1:
				output_list.append(int(intermediate_str))
		elif len(intermediate_str) != 0:
			output_list.append(int(intermediate_str))
			intermediate_str = ''
	return output_list

def func():
	a = input()
	output_str = ''
	for i in range(int(a)):
		b = input()
		(n, x) = string_split(b, ' ')
		first_flat_numb = 1
		floor = 1
		if n == 1 or n == 2:
			output_str += str(floor) + '\n'
		else:
			while n >= first_flat_numb:
				floor += 1
				first_flat_numb = (floor - 2) * x + 3
			output_str += str(floor - 1) + '\n'
	return output_str[:-1]
print(func())


import sys, os.path
from collections import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		n -= 2
		c = 1
		while n > 0:
			c += 1
			n -= x
		print(c)


from sys import stdin, stdout
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		print((n - 3) // x + 2)


from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from fractions import Fraction
from decimal import Decimal
import math
mod = pow(10, 9) + 7

def sp():
	return map(int, input().split())

def sli():
	return list(sp())

def fun(x):
	return sum((int(i) for i in str(x)))

def find(n):
	if n == 3:
		return 3
	while 1:
		flag = 0
		for i in range(2, int(sqrt(n)) + 1):
			if n % i == 0:
				n += 1
				break
			if i == int(sqrt(n)):
				flag = 1
				break
		if flag:
			break
	return n
t = int(input())
for _ in range(t):
	(n, x) = sp()
	if n == 1:
		print(1)
	else:
		print(1 + ceil((n - 2) / x))


import sys

def solve(n1, n2):
	n1 -= 2
	if n1 <= 0:
		return 1
	elif n1 % n2 == 0:
		return n1 // n2 + 1
	else:
		return int(n1 / n2 + 1) + 1
for i in range(int(sys.stdin.readline())):
	a = list(map(int, sys.stdin.readline().split()))
	(z1, z2) = (a[0], a[1])
	print(solve(z1, z2))


for _ in range(int(input())):
	(n, hnum) = map(int, input().split())
	x = 2
	y = 1
	while x < n:
		x += hnum
		y += 1
	print(y)


t = int(input())

def find(n, x):
	if n <= 2:
		return 1
	level = 1
	while True:
		if n >= (level - 1) * x + 2 + 1 and n < level * x + 3:
			return level + 1
		level += 1
for i in range(t):
	(n, x) = [int(x) for x in input().split(' ')]
	print(find(n, x))


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from math import ceil
for _ in range(int(read())):
	(n, x) = readi()
	n -= 2
	ans = max(0, ceil(n / x)) + 1
	print(ans)


from math import ceil
for _ in range(int(input())):
	(n, x) = [int(_) for _ in input().split()]
	if n == 1 or n == 2:
		print(1)
	else:
		print(ceil((n - 2) / x) + 1)


def floor(n, x):
	if n <= 2:
		return 1
	n = n - 2
	ans = n // x
	fans = n / x
	if ans < fans:
		return ans + 2
	return ans + 1
m = int(input())
for i in range(m):
	(n, x) = [int(x) for x in input().split()]
	print(floor(n, x))


def floor(n, x):
	if n < 3:
		return 1
	n = n - 2
	num = 1 + n // x
	if n % x != 0:
		num += 1
	return num
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	print(floor(n, x))


n = int(input())
y = [0 for j in range(n)]
for i in range(n):
	(n1, x) = map(int, input().split())
	y[i] = 1 if n1 <= 2 else (n1 - 3) // x + 2
for i in range(n):
	print(y[i])


import math
t = int(input())
for tc in range(0, t):
	inp = input().split()
	n = int(inp[0])
	x = int(inp[1])
	if n <= 2:
		print(1)
	else:
		val2 = math.ceil((n - 2) / x) + 1
		val = (n - 2) // x + 1
		print(val2)


t = int(input())
for i in range(t):
	(y, x) = map(int, input().split())
	if y <= 2:
		print(1)
	else:
		n = (y - 2) / x + 1
		if int(n) >= n:
			print(int(n))
		else:
			print(int(n) + 1)


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	s = 2
	i = 1
	while 1:
		if s < a:
			s += b
			i += 1
		else:
			break
	print(i)


def floor_number(num, x, max_floor):
	max_number = (max_floor - 1) * x + 2
	p = True
	while p:
		if num <= max_number:
			print(max_floor)
			p = False
		else:
			max_floor += 1
			max_number = (max_floor - 1) * x + 2
while True:
	try:
		t = int(input())
		while t != 0:
			k = input()
			(n, x) = k.split()
			n = int(n)
			x = int(x)
			floor_number(n, x, 1)
			t = t - 1
	except EOFError:
		break


gt = lambda : map(int, input().split())
(t,) = gt()
exec('n,x=gt();print((n+x-3)//x+1 if n>2 else 1);' * t)


import math

def answer(a, b):
	if a <= 2:
		return 1
	t_f = n - 2
	return math.ceil(t_f / x) + 1
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	print(answer(n, x))


import math
tests = int(input())
for test in range(tests):
	(number, floor) = [int(i) for i in input().split()]
	counter = 0
	answer = number - 2
	if answer <= 0:
		print(1)
	else:
		answer = math.ceil(answer / floor)
		answer += 1
		print(answer)


import math
t = int(input())
for i in range(t):
	(n, x) = input().split()
	(n, x) = (float(n), float(x))
	if n < 3:
		floor = 1
	else:
		floor = (n - 2) / x
		floor = math.ceil(floor) + 1
	print(floor)


from sys import stdin

def ip():
	return [int(i) for i in stdin.readline().split()]

def sp():
	return [str(i) for i in stdin.readline().split()]
import math

def solve(n, x):
	if n <= 2:
		return 1
	n -= 2
	return 1 + int(math.ceil(n / x))
t = int(input())
for _ in range(t):
	(n, x) = ip()
	print(solve(n, x))


import sys
input = sys.stdin.readline

def main():
	(n, x) = map(int, input().split())
	last = 2
	ans = 1
	while last < n:
		last += x
		ans += 1
	print(ans)
for _ in range(int(input())):
	main()


from collections import *
from itertools import *
from bisect import *

def inp():
	return int(input())

def arrinp():
	return [int(x) for x in input().split()]

def main():
	t = inp()
	for _ in range(t):
		(n, x) = arrinp()
		if n <= 2:
			print(1)
			continue
		else:
			n -= 2
			floor = n // x + (n % x != 0) + 1
			print(floor)
main()


t = int(input())
while t:
	(n, x) = [int(n) for n in input().split()]
	(count, ans) = (2, 0)
	if n <= 2:
		print('1')
		t -= 1
		continue
	for i in range(2, n):
		count += x
		if count >= n:
			ans = i
			break
	print(ans)
	t -= 1


t = int(input())
li = []
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		f = 1
	else:
		f = 2 + (n - 3) // x
	li.append(f)
for j in range(len(li)):
	print(li[j])


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)
for xyz in range(0, int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		a = 1
		cf = 3
		for i in range(0, 100000000):
			a += 1
			cf += x
			if cf > n:
				print(a)
				break


def getFloor(n, x):
	if n == 1 or n == 2:
		return 1
	n -= 3
	return n // x + 2
T = int(input())
for t in range(T):
	(n, x) = [int(i) for i in input().split(' ')]
	ans = getFloor(n, x)
	print(ans)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	(n, x) = inm()
	print(max(0, (n + x - 3) // x) + 1)


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k, modulus=1):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
		res %= modulus
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, x) = int_array()
	if n <= 2:
		print(1)
	else:
		n -= 2
		print(int(1 + ceil(n / x)))


import sys
input = sys.stdin.readline
for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		r = (n - 2) // x + 2
		if (n - 2) % x == 0:
			r -= 1
		print(r)


import sys
import math
tests = int(input())
for i in range(tests):
	(n, x) = [int(i) for i in input().split()]
	if n <= 2:
		print(1)
	else:
		print(math.floor((n - 3) / x) + 2)


cars = ['Ford', 'Volvo', 'BMW']
testCases = input()
listAnswer = []

def my_function(AppartmentNumber, floorcount):
	currentApartmentCount = 2
	aukstai = 1
	if currentApartmentCount >= AppartmentNumber:
		return 1
	else:
		aukstai = aukstai + 1
	while currentApartmentCount < AppartmentNumber:
		currentApartmentCount = currentApartmentCount + floorCount
		if currentApartmentCount >= AppartmentNumber:
			return aukstai
		else:
			aukstai = aukstai + 1
testCases = int(testCases)
for x in range(testCases):
	(petiasApartmentNumber, floorCount) = [int(x) for x in input().split()]
	my_function(petiasApartmentNumber, floorCount)
	listAnswer.append(my_function(petiasApartmentNumber, floorCount))
for x in range(len(listAnswer)):
	print(listAnswer[x])


import sys
import math
for test in range(int(input())):
	(n, k) = map(int, sys.stdin.readline().split())
	if n == 1 or n == 2:
		print('1')
	else:
		print(math.ceil((n - 2) / k) + 1)


import math
t = int(input())
n = list()
x = list()
for i in range(t):
	l = input().split()
	n.append(int(l[0]))
	x.append(int(l[1]))
for i in range(t):
	print(1 if n[i] <= 2 else math.ceil((n[i] - 2) / x[i]) + 1)


import sys
import math
for i in range(0, int(sys.stdin.readline())):
	nx = list(map(int, sys.stdin.readline().split()))
	if nx[1] > 1:
		flur = math.floor((nx[0] - 3) / nx[1] + 2)
	else:
		flur = nx[0] - 1
		if flur == 0:
			flur = 1
	sys.stdout.write(str(flur))
	sys.stdout.write('\n')


num = int(input())
floor = []
nums = []
for J in range(num):
	nums.append([int(i) for i in input().split()])
for (n, x) in nums:
	if n < 3:
		floor.append(1)
	elif (n - 2) % x > 0:
		floor.append((n - 2) // x + 2)
	else:
		floor.append((n - 2) // x + 1)
for i in floor:
	print(str(i))


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline()[:-1]

def SI():
	return sys.stdin.buffer.readline()[:-1].decode()
for _ in range(II()):
	(n, x) = MI()
	if n < 3:
		print(1)
	else:
		print((n - 3 + x) // x + 1)


t = int(input())
for _ in range(t):
	line = input().split()
	n = int(line[0]) - 2
	if n < 1:
		print(1)
	else:
		x = int(line[1])
		if n % x == 0:
			print(n // x + 1)
		else:
			print(n // x + 2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	f = 1
	apart = 2
	while n > apart:
		apart += x
		f += 1
	print(f)


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import defaultdict
from pprint import pprint
from math import ceil

def main():
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		return
	n -= 2
	print(1 + ceil(n / x))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	print((n - 3) // k + 2)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	f = 1
	n -= 2
	while n > 0:
		n -= x
		f += 1
	print(f)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	if a[0] <= 2:
		print(1)
	else:
		x = a[0] - 2
		is_whole = x % a[1] == 0
		if is_whole == True:
			print(1 + x // a[1])
		else:
			print(1 + x // a[1] + 1)


import os
from sys import stdin, stdout

class Input:

	def __init__(self):
		self.lines = stdin.readlines()
		self.idx = 0

	def line(self):
		try:
			return self.lines[self.idx].strip()
		finally:
			self.idx += 1

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def known_tests(self):
		(num_of_cases,) = self.array()
		for case in range(num_of_cases):
			yield self

	def unknown_tests(self):
		while self.idx < len(self.lines):
			yield self

def problem_solver():

	def solver(inpt):
		(n, x) = inpt.array()
		if n < 3:
			print(1)
		else:
			f = (n - 3) // x + 2
			print(f)
	return solver
try:
	solver = problem_solver()
	for tc in Input().known_tests():
		solver(tc)
except Exception as e:
	import traceback
	traceback.print_exc(file=stdout)


def ceil(a, b):
	return (a + b - 1) // b
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	n -= 2
	ans = 1
	print(ceil(n, x) + 1)


for i in range(int(input())):
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	floor = 2
	p = 3
	while 1:
		if n == 1 or n == 2:
			print(1)
			break
		elif p <= n <= p + x - 1:
			print(floor)
			break
		else:
			floor += 1
			p = p + x


from math import ceil
t = int(input())
for cases in range(t):
	(n, x) = list(map(int, input().strip().split()))
	if n <= 2:
		print(f'1')
	else:
		print(f'{ceil((n - 2) / x) + 1}')


from sys import stdout, stdin
from io import IOBase, BytesIO
from os import read, write, fstat
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size: int=...):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
input = lambda : stdin.readline().rstrip('\r\n')
t = int(input())
f = max
for _ in range(t):
	(n, x) = map(int, input().split())
	print(f(1, (n - 3) // x + 2))


from collections import deque
from math import ceil, sqrt
import sys
for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	if n < 3:
		print(1)
	else:
		print(ceil((n - 2) / x) + 1)


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	if n <= 2:
		print(1)
	else:
		(f, r) = divmod(n - 2, k)
		answer = 1 + f + int(r > 0)
		print(answer)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print(1)
	elif (n - x - 2) / x == (n - x - 2) // x:
		print(int((n - x - 2) // x) + 2)
	else:
		print(int((n - x - 2) // x) + 3)


try:
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		if n == 1 or n == 2:
			print('1')
		else:
			z = x
			floor = 2
			i = 2
			while True:
				if n >= 3 and n <= x + 2:
					print('2')
					break
				elif n >= x + 3 and n <= x * i + 2:
					print(floor + 1)
					break
				else:
					i += 1
					floor += 1
except:
	pass


from math import ceil
for _ in [*open(0)][1:]:
	(n, x) = map(int, _.split())
	if n == 1 or n == 2:
		print(1)
	else:
		print(ceil((n - 2) / x) + 1)


def main():
	n = int(input())
	for i in range(n):
		(a, b) = input().split()
		a = int(a)
		b = int(b)
		if a < 2:
			print(a)
		elif int((a - 2) % b) == 0:
			print(int((a - 2) / b) + 1)
		else:
			print(int((a - 2) / b) + 2)
main()


nc = int(input())
for _ in range(nc):
	(n, x) = map(int, input().rstrip().split())
	first_floor = [1, 2]
	bal_apts = n - 2
	if n in first_floor:
		print(1)
	else:
		if bal_apts % x == 0:
			floor = bal_apts // x
		else:
			floor = bal_apts // x + 1
		print(floor + 1)


for i in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	if n <= 2 and n > 0:
		print(1)
	elif x == 0 or n == 0:
		print(0)
	else:
		y = n - 2
		if y % x == 0:
			print(y // x + 1)
		else:
			print(y // x + 2)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a <= 2:
		print(1)
	else:
		print((a - 3) // b + 2)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	t = n - 2
	if t <= 0:
		print(1)
	else:
		a = (t + k - 1) // k
		print(a + 1)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x - 2 > 0:
		print((x - 2) // y + [2, 1][(x - 2) % y == 0])
	else:
		print(1)


T = int(input())
while T != 0:
	(n, x) = [int(i) for i in input().split()]
	if n <= 2:
		print(1)
	else:
		n -= 2
		k = int(n / x)
		if n % x == 0:
			k += 1
		else:
			k += 2
		print(k)
	T -= 1


import math as m
t = int(input())
for xyz in range(t):
	(n, x) = (int(i) for i in input().split())
	if n == 1 or n == 2:
		print('1')
	else:
		for fl in range(1, 100000):
			if n >= (fl - 1) * x + 2 + 1 and n <= fl * x + 2:
				print(fl + 1)
				break


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	c = 2
	ans = 1
	while c < n:
		c += x
		ans += 1
	print(ans)


import math
t = int(input())
li = []
for i in range(t):
	(n, x) = map(int, input().split())
	li.append((n, x))
for (n, x) in li:
	if n <= 2:
		print(1)
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print(math.floor((n - 2) / x) + 2)


def inp():
	return int(input())

def minp():
	return map(int, input().split())

def linp():
	return list(map(int, input().split()))
from math import ceil
for _ in range(inp()):
	(n, x) = minp()
	if n < 3:
		print(1)
	else:
		print(ceil((n - 2) / x) + 1)


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(n, x):
	console('----- solving ------')
	if n <= 2:
		return 1
	return -(-(n - 2) // x) + 1

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	(n, k) = list(map(int, input().split()))
	res = solve(n, k)
	print(res)


from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n, x) = gil()
	cnt = 1
	n -= min(n, 2)
	while n:
		n -= min(n, x)
		cnt += 1
	print(cnt)


t = int(input())
ans = []
for i in range(t):
	(n, x) = map(int, input().split())
	floor = 1
	y = x
	if n <= 2:
		ans.append(floor)
	else:
		while 2 + x < n:
			x += y
			floor += 1
		ans.append(int(floor + 1))
for i in range(t):
	print(ans[i])


a = int(input())
for _ in range(a):
	(n, x) = map(int, input().split())
	k = 2
	ans = 1
	while k < n:
		k += x
		ans += 1
	print(ans)


import math

def solve():
	(n, x) = list(map(int, input().split()))
	ans = 1
	n -= 2
	while n > 0:
		ans += 1
		n -= x
	print(ans)
t = 1
t = int(input())
for _ in range(0, t):
	solve()


import math

def main():
	N = int(input())
	for _ in range(N):
		(a, b) = map(int, input().split())
		print(solve(a, b))

def solve(a, b):
	if a - 2 <= 0:
		return 1
	a -= 2
	return math.ceil(a / b) + 1
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print((-((2 - a) // b) + 1) * (a > 2) + 1 * (a < 3))


import sys
from math import floor

def solve(n, x):
	if n <= 2:
		return 1
	else:
		return (n - 3) // x + 2

def main():
	t = int(sys.stdin.readline().strip())
	for i in range(t):
		(n, x) = [int(i) for i in sys.stdin.readline().strip().split(' ')]
		print(solve(n, x))
main()


from math import ceil

def func(n, x):
	if n <= 2:
		print(1)
		return
	m = ceil((n - 2) / x)
	print(m + 1)
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	func(n, x)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def ceil(x, y=1):
	return int(-(-x // y))
import math
from collections import defaultdict
for _ in range(ri()):
	(n, x) = ria()
	if n <= 2:
		wi(1)
	else:
		n -= 2
		ans = 1 + math.ceil(n / x)
		wi(ans)


import sys, os, io
input = sys.stdin.readline
T = int(input())
ans = [0] * T
for t in range(T):
	(n, x) = map(int, input().split())
	if n >= 2:
		ans[t] = 0 - -(n - 2) // x + 1
	else:
		ans[t] = 1
print(*ans, sep='\n')


import math
t = int(input())
while t > 0:
	a = list(map(int, input().strip().split()))
	n = a[0]
	x = a[1]
	if n == 1 or n == 2:
		print(1)
	else:
		n = n - 2
		ans = math.ceil(n / x)
		print(ans + 1)
	t -= 1


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	if (n - 2) % k != 0:
		print((n - 2) // k + 2)
	else:
		print((n - 2) // k + 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ans = 1
	c = 0
	for i in range(3, 1100, x):
		c += 1
		if n == i:
			break
		elif n < i:
			c -= 1
			break
	print(ans + c)


def solve(n, x):
	if n <= 2:
		return 1
	c = 1
	j = 1
	o = 2
	while n > o:
		o += x
		c += 1
	return c
t = int(input())
while t:
	(n, x) = map(int, input().split(' '))
	print(solve(n, x))
	t -= 1


import math
testcase = int(input())
while testcase > 0:
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		ans = math.ceil((n - 2) / x)
		print(ans + 1)
	testcase -= 1


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	for j in range(1000):
		if j == 0:
			if n == 1 or n == 2:
				print(j + 1)
				break
		elif j == 1:
			if 3 <= n <= x + 2:
				print(j + 1)
				break
		else:
			a = j - 1
			if a * x + 3 <= n <= j * x + 2:
				print(j + 1)
				break


def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	for p in range(n + 1):
		if prime[p]:
			print(p)
nV = 4
INF = 999

def floyd_warshall(G):
	distance = list(map(lambda i: list(map(lambda j: j, i)), G))
	for k in range(nV):
		for i in range(nV):
			for j in range(nV):
				distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j])
	print_solution(distance)
from collections import defaultdict

def print_solution(distance):
	for i in range(nV):
		for j in range(nV):
			if distance[i][j] == INF:
				print('INF', end=' ')
			else:
				print(distance[i][j], end='  ')
		print(' ')
import math
tt = int(input())
for _ in range(tt):
	(n, x) = map(int, input().split())
	n -= 2
	ans = 1
	while n > 0:
		ans += 1
		n -= x
	print(ans)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
num = int(z())
for _ in range(num):
	(n, m) = zz()
	if n <= 2:
		print(1)
	else:
		print((n - 3) // m + 2)


t = int(input())
i = 0
while i < t:
	l = list(input().split())
	n = int(l[0])
	x = int(l[1])
	if n <= 2:
		print(1)
	else:
		print((n - 3) // x + 2)
	i += 1


for i in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	if n < 3:
		print(1)
	else:
		temp = (n - 2) // x
		temp += 1 if (n - 2) % x != 0 else 0
		print(1 + temp)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n > k:
		cnt = 1
		ans = n - 2
		while ans > 0:
			cnt += 1
			ans -= k
		print(cnt)
	elif n == 1 or n == 2:
		print(1)
	else:
		print(2)


import sys
import math
t = int(sys.stdin.readline().strip())
for _ in range(t):
	line = sys.stdin.readline().strip().split()
	(n, x) = list(map(int, line))
	res = 1 if n <= 2 else math.ceil((n - 2) / x) + 1
	print(res)


import math
for _ in range(int(input())):
	nx = list(map(int, input().split()))
	n = nx[0]
	x = nx[1]
	if n == 1 or n == 2:
		print('1')
	elif n > 2 and n <= x:
		print('2')
	else:
		print(math.ceil((n - 2 + 1 * x) / x))


for i in range(int(input())):
	(n, x) = map(int, input().split())
	t = n - 2
	if t > 0:
		r = t % x
		u = t // x
	else:
		r = 0
		u = 0
	if r > 0:
		print(1 + u + 1)
	else:
		print(1 + u)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	flag = True
	f = 1
	if n <= 2:
		print(1)
		flag = False
	else:
		a = (n - 3) / x
		b = (n - 2 - x) / x
		c = int(max(a, b)) + 2
		print(c)


n = int(input())
for i in range(n):
	st = input().split()
	num = int(st[0])
	x = int(st[1])
	id = 1
	maxim = 2
	while maxim < num:
		maxim += x
		id += 1
	print(id)


a = []
b = []
n = int(input())
for i in range(n):
	(c, d) = input().split()
	a.append(int(c))
	b.append(int(d))

def checki(x, y):
	z = y
	a = 1
	y = y + 2
	if x <= 2:
		return a
	while True:
		a = a + 1
		if x <= y:
			return a
			break
		y = y + z
for i in range(n):
	print(checki(a[i], b[i]))


def Floornum(house, num):
	count = 2
	flag = 0
	if house <= 2:
		return 1
	else:
		while flag == 0:
			if house >= (count - 2) * num + 3 and house <= (count - 1) * num + 2:
				floor_count = count
				flag = 1
				return floor_count
			count += 1
test = int(input())
for i in range(0, test):
	input_int_array = [int(x) for x in input().split()]
	house = input_int_array[0]
	num = input_int_array[1]
	floornum = Floornum(house, num)
	print(floornum)


import math as m
n = int(input())
for t in range(n):
	(a, b) = list(map(int, input().split()))
	if a - 2 <= 0:
		print(1)
	else:
		a = a - 2
		c = m.ceil(a / b)
		print(c + 1)


t = int(input())
l = []
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	if n <= 2:
		l.append(1)
	else:
		p = n - 2
		q = p // x
		if p % x != 0:
			q += 1
		l.append(q + 1)
for j in range(t):
	print(l[j])


import math
Tests = int(input())
for i in range(Tests):
	inputs = list(map(int, input().split()))
	Target = int(inputs[0])
	Apartments = int(inputs[1])
	if Target < 3:
		print(1)
		continue
	Target = Target - 2
	ANS = math.ceil(Target / Apartments)
	print(ANS + 1)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		c = 2
		start = 3
		while start < 1001:
			if start <= n and n <= start + x - 1:
				print(c)
				break
			else:
				c += 1
				start += x


from math import floor
t = int(input())
for i in range(t):
	(n, x) = [int(y) for y in input().split()]
	if n == 1 or n == 2:
		print(1)
		continue
	if x == 1:
		print(n - x)
		continue
	q = floor(n / x)
	l = q * x
	z = n - l
	if z == 0 and n != x and (x == 2):
		print(q)
		continue
	if z <= 2:
		print(q + 1)
		continue
	if z > 2:
		print(q + 2)


s = input()
t = int(s)
l = []
for i in range(t):
	a = input().split()
	b = [int(x) for x in a]
	l.append(b)

def roof(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1
for x in l:
	if x[0] < 3:
		print(1)
	else:
		print(roof(x[0] - 2, x[1]) + 1)


from math import ceil

def main():
	for i in range(int(input())):
		(n, x) = map(int, input().split())
		if n <= 2:
			print('1')
		else:
			print((n - 3) // x + 2)
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split(' '))
	if n == 1 or n == 2:
		print(1)
	else:
		n = n - 2
		res = n // x + 1
		if n % x:
			res += 1
		print(res)


import bisect
import array
import functools
import math
T = int(input())
for Tid in range(T):
	(n, k) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print((n - 2 + k - 1) // k + 1)


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ans = 1
	l = (ans - 1) * x + 2
	while l < n:
		ans += 1
		l = (ans - 1) * x + 2
	print(ans)


n = int(input())
l = []
for i in range(0, n):
	s = [int(x) for x in input().split()]
	l.append(s)
for k in range(0, n):
	p = l[k][0] - 2
	p1 = p % l[k][1]
	if l[k][0] == 1 or l[k][0] == 2:
		print(1)
	elif p1 != 0:
		print(p // l[k][1] + 2)
	else:
		print(p // l[k][1] + 1)


import sys
t = int(sys.stdin.readline().strip())
for _ in range(t):
	(n, x) = map(int, sys.stdin.readline().strip().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		k = n // x
		if x * k == n:
			print(k + 1)
		else:
			print(k + 2)


import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, x) = get_ints()
	if n == 1 or n == 2:
		print(1)
		continue
	if n > x:
		if (n - 2) % x == 0:
			a = (n - 2) // x
		else:
			a = (n - 2) // x + 1
		print(1 + a)
	else:
		print(2)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	x = 3
	y = k + 2
	g = 1
	h = 1
	if n <= 2:
		print(1)
	while n > 2:
		if x <= n and y >= n:
			print(g + 1)
			break
		else:
			x += k
			g += 1
			y = g * k + 2


import math
t = int(input())
i = 1
while i <= t:
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print('1')
	else:
		j = 3
		ans = 1
		while j <= n:
			ans += 1
			j += x
		print(ans)
	i += 1


t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	arr = []
	arr.append(2)
	num = int(n / x)
	for i in range(num + 1):
		arr.append(x)
	s = 0
	for i in range(0, len(arr)):
		s = s + arr[i]
		if s >= n:
			print(i + 1)
			break


t = int(input())
for i in range(t):
	c = 2
	(n, x) = map(int, input().split())
	l = x + 2
	for j in range(1, n + 1):
		if n < 3:
			print('1')
			break
		if n > 2 and n <= l:
			print(c)
			break
		l = l + x
		c = c + 1


def main():
	t = int(input())
	for _ in range(t):
		(n, x) = (int(j) for j in input().split())
		if n < 3:
			print('1')
			continue
		n = n - 2
		ans = n // x + 1
		if n % x != 0:
			ans = ans + 1
		print(ans)
main()


import math
t = int(input())
while t:
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
	else:
		print(int(math.ceil((n - 2) / x) + 1))
	t -= 1


t = int(input())
a = list()
k = 0
f = 0
for i in range(0, t):
	(n, x) = map(int, input().split())
	k = 2
	f = 1
	while k < n:
		f += 1
		k = (f - 1) * x + 2
	a.append(f)
for i in range(0, len(a)):
	print(a[i])


t = int(input())
for i in range(t):
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	floor = 1
	apartments = 2
	while apartments < n:
		apartments += x
		floor += 1
	print(floor)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		a = [[1, 2]]
		for i in range(3, n + k, k):
			a.append([j for j in range(i, i + k)])
		for j in a[::-1]:
			if n in j:
				print(a.index(j) + 1)


T = int(input())
for i in range(T):
	(n, x) = map(lambda t: int(t), input().split())
	if n <= 2:
		print(1)
	else:
		print(int((n - 3) / x) + 2)


import math
t = int(input())
while t != 0:
	(n, x) = [int(p) for p in input().split()]
	if n == 1 or n == 2:
		print(1)
	else:
		floor = 1
		flat = 3
		while flat <= n:
			flat += x
			floor += 1
		print(floor)
	t = t - 1


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
import io
import os
import operator
input = sys.stdin.readline
import random
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for _ in range(inin()):
	(n, x) = cin()
	if n - 2 <= 0:
		print(1)
	else:
		ans = (n - 2 + x - 1) // x + 1
		print(ans)


def solve(n, x):
	if n < 2:
		return 1
	(k, r) = divmod(n - 2, x)
	add = 1 if r else 0
	return k + 1 + add
t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split(' ')]
	print(solve(n, x))


t = int(input())
for i in range(t):
	num = input().split(' ')
	n = int(num[0])
	x = int(num[1])
	if n <= 2:
		print(1)
	else:
		if (n - 2) % x != 0:
			sp = 1
		else:
			sp = 0
		print(int((n - 2) / x) + sp + 1)


import math

def Number_of_stage(n, x):
	if int(n) in range(1, 3):
		return 1
	else:
		return math.ceil((n - 2) / x + 1)
_list = []
n = int(input())
for i in range(0, n):
	(n, x) = input().split(' ', 1)
	_list.append(Number_of_stage(float(n), float(x)))
for i in _list:
	print(i)


from decimal import Decimal
from math import ceil
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().strip().split())
	if n == 1 or n == 2:
		print(1)
	else:
		ans = ceil(Decimal(n - 2) / Decimal(k)) + 1
		print(ans)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	a -= 2
	if a <= 0:
		print(1)
	else:
		k = 0
		if a % b > 0:
			k = 1
		print(a // b + 1 + k)


t = int(input())
result = []
for test in range(t):
	(n, x) = map(int, input().split())
	if n > 2:
		if (n - 2) % x == 0:
			result.append((n - 2) // x + 1)
		else:
			result.append((n - 2) // x + 2)
	else:
		result.append(1)
for res in result:
	print(res)


import math
t = int(input())
for tc in range(t):
	line = input().split()
	(n, x) = (int(line[0]), int(line[1]))
	if n == 1 or n == 2:
		print('1')
		continue
	ans = math.ceil((n - 2) / x) + 1
	print(ans)


t = int(input())
for case in range(t):
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print(1)
	else:
		n -= 3
		ans = 2 + n // x
		print(ans)


import math
import sys
t = int(input())
for cs in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print((n - 3) // x + 2)


t = int(input())
for i in range(0, t):
	inp = input()
	arr = inp.split()
	n = int(arr[0])
	x = int(arr[1])
	sum = 2
	cnt = 1
	while True:
		if sum >= n:
			break
		sum += x
		cnt += 1
	print(cnt)


import math
t = int(input())
for i in range(t):
	b = list(map(int, input().split()))
	(n, p) = (b[0], b[1])
	l = 2
	if n <= 2:
		print(1)
	else:
		while l <= 2000:
			if n in range((l - 2) * p + 3, (l - 1) * p + 3):
				print(l)
				break
			l += 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	f = 1
	if n > 2:
		k = (n + 2 * x - 3) // x
	else:
		k = 1
	print(k)


def floorNo(n, x):
	if n == 1 or n == 2:
		return 1
	elif (n - 2) % x == 0:
		return (n - 2) // x + 1
	else:
		return (n - 2) // x + 2
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print(floorNo(n, x))


def apartment(n, x):
	if n <= 2:
		return 1
	tmp = n - 2
	if tmp % x == 0:
		return tmp // x + 1
	else:
		return tmp // x + 2
n = int(input())
res = []
for i in range(n):
	arr = list(map(int, input().split()))
	res.append(apartment(arr[0], arr[1]))
for j in res:
	print(j)


import math
ans = []
for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		ans += [1]
	else:
		ans += [math.ceil((n - 2) / x) + 1]
print(*ans, sep='\n')


def level(h):
	a = h[0]
	b = h[1]
	(a, b) = (int(a), int(b))
	i = 1
	a -= 2
	while a > 0:
		a -= b
		i += 1
	return i
t = int(input())
for _ in range(t):
	print(level(input().split(' ')))


import math
t = int(input())
while t:
	inp = input().split()
	n = int(inp[0])
	x = int(inp[1])
	if n <= 2:
		print(1)
	else:
		n -= 2
		print(math.ceil(n / x) + 1)
	t -= 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	n -= 2
	if n <= 0:
		print(1)
	else:
		(q, r) = divmod(n, x)
		ans = q + 2 - (1 if r == 0 else 0)
		print(ans)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	(n, k) = value()
	if n <= 2:
		print(1)
	else:
		n -= 2
		res = ceil(n / k)
		print(res + 1)


t = int(input())
apartment = []
if 1 <= t <= 1000:
	for _ in range(t):
		(n, x) = map(int, input().split())
		a = n // x + 1
		steps = 3
		first_floor = [[1, 2]]
		floors = []
		for i in range(a):
			floors.append([])
			for j in range(x):
				floors[i].append(steps)
				steps += 1
		all_floors = first_floor + floors
		for i in range(len(all_floors)):
			if n in all_floors[i]:
				apartment.append(i + 1)
print(*apartment, sep='\n')


for iii in range(int(input())):
	(n, x) = map(int, input().split())
	l = [1, 2]
	if n == 1 or n == 2:
		print('1')
	else:
		ans = 0
		c = 1
		while n not in l:
			for i in range(x):
				l.append(l[-1] + 1)
			c += 1
			if l[-1] >= n:
				ans = c
				break
		print(ans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
from functools import lru_cache
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, x) = li()
	if n <= 2:
		print(1)
	else:
		n -= 2
		print(1 + n // x + (1 if n % x else 0))


import sys
import math
input = sys.stdin.readline
cases = int(input())
for case in range(cases):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	print((n - 3) // x + 2)


from sys import stdin, stdout
from math import ceil
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	(n, x) = mp()
	if n <= 2:
		pr(1)
		return
	n -= 2
	ans = ceil(n / x) + 1
	pr(ans)
for _ in range(inp()):
	solve()


import math

def solve(n, x):
	n = max(n - 2, 0)
	return math.ceil(n / x) + 1
n = int(input())
for i in range(n):
	(x, y) = map(lambda x: int(x), input().split())
	print(solve(x, y))


a = int(input())
for i in range(a):
	inp = input().split()
	f = 1
	b = int(inp[0])
	c = int(inp[1])
	if b <= 2:
		print(f)
	else:
		f = 0
		if (b - 2) % c == 0:
			f = (b - 2) // c + 1
		else:
			f = (b - 2) // c + 2
		print(f)


import math
test = int(input())
for i in range(test):
	(n, k) = [int(x) for x in input().split(' ')]
	if n < 3:
		print(1)
	else:
		ans = math.floor((n - 3) / k) + 1
		print(ans + 1)


import math
try:
	test_cases = int(input())
	for _ in range(test_cases):
		(apartment_number, apartment_on_floor) = map(int, input().split())
		if apartment_number == 1 or apartment_number == 2:
			floor = 1
		else:
			floor = math.ceil((apartment_number - 2) / apartment_on_floor) + 1
		print(floor)
except EOFError:
	pass


from sys import stdin, stdout
import math
from collections import deque
input = stdin.readline

def print(*args, end='\n'):
	s = []
	for i in args:
		s.append(str(i) + ' ')
	s = ''.join(s)
	stdout.write(s + end)

def solve():
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		return
	print(math.ceil((n - 2) / x) + 1)
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		floor = 0
		l = []
		prev = 2
		while n not in l:
			floor += 1
			l = [i for i in range(prev + 1, prev + x + 1)]
			prev = l[len(l) - 1]
		print(floor + 1)


n = int(input())
for i in range(n):
	count = 1
	floor = 2
	(a, x) = [int(i) for i in input().split()]
	while floor < a:
		floor += x
		count += 1
	print(count)


t = int(input())
for i in range(t):
	(n, x) = [int(j) for j in input().split()]
	c = 0
	n -= 2
	c += 1
	while n > 0:
		n -= x
		c += 1
	print(c)


T = int(input())
for case in range(T):
	(n, x) = map(int, input().split(' '))
	if n <= 2:
		print(1)
	elif (n - 2) % x == 0:
		print((n - 2) // x + 1)
	else:
		print((n - 2) // x + 2)


def linput():
	return [int(i) for i in input().split()]

def nod(a, b):
	while a != 0 and b != 0:
		if a > b:
			a = a % b
		else:
			b = b % a
	return a + b
qwertyyyyyy = int(input())
for ______ in range(qwertyyyyyy):
	(n, x) = linput()
	if n < 2:
		print(1)
	else:
		print((n - 3) // x + 2)


import math

def process():
	(n, x) = map(int, input().split())
	if n < 3:
		return 1
	n -= 2
	return 1 + math.ceil(n / x)
for i in range(int(input())):
	print(process())


import math as m
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		i = 1
		no = 0
		while i <= n:
			if n <= i * x + 2:
				print(i + 1)
				break
			i += 1


import math

def get_floor(apt_num, apt_per_floor):
	if apt_num <= 2:
		return 1
	apt_num_shifted = apt_num - 2
	estimated_floor = int(math.ceil(apt_num_shifted / apt_per_floor))
	return estimated_floor + 1
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	print(get_floor(n, x))


t = int(input())
while t > 0:
	f = 0
	(n, x) = map(int, input().split())
	while True:
		if n <= 0:
			break
		if f == 0:
			f += 1
			n -= 2
		else:
			f += 1
			n -= x
	print(f)
	t -= 1


import math
prime = [True for i in range(10 ** 6 + 1)]

def SieveOfEratosthenes(n):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
T = int(input())
for _ in range(0, T):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print(int((n - 3) / x + 2))


from math import *
import threading
import sys

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li
INF = 1000000000.0
primes = SieveOfEratosthenes(1300000)
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	f = 0
	st = 2
	while True:
		if st < n:
			st += x
			f += 1
		else:
			print(f + 1)
			break


n = int(input())
for i in range(n):
	(a, t) = map(int, input().split(' '))
	if a <= 2:
		print(1)
	elif (a - 2) % t == 0:
		print((a - 2) // t + 1)
	else:
		print((a - 2) // t + 2)


x = int(input())
b = []
for i in range(x):
	a = list(map(int, input().strip().split()))
	p = a[0]
	q = a[1]
	r = (p - 2) / q
	if p == 1 or p == 2:
		b.append(1)
	elif r % 1 == 0:
		b.append(int(r + 1))
	elif r % 1 != 0:
		b.append(int(r + 2))
for g in b:
	print(g)


from math import ceil
t = int(input())
for _ in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	if n < 3:
		print(1)
	else:
		print(ceil((n - 2) / k) + 1)


import math
import sys

class Graph:

	def __init__(self, Nodes, is_directed=False):
		self.nodes = Nodes
		self.adj_list = {}
		self.is_directed = is_directed
		for node in self.nodes:
			self.adj_list[node] = []

	def add_edge(self, u, v):
		self.adj_list[u].append(v)
		if self.is_directed == False:
			self.adj_list[v].append(u)

	def print_graph(self):
		for node in self.nodes:
			print(node, '->', self.adj_list[node])

	def degree_node(self, node):
		return len(self.adj_list[node])

	def dfsUTIL(self, v, visited, parents=[]):
		visited[v] = True
		for i in self.adj_list[v]:
			if visited[i] == False:
				self.dfsUTIL(i, visited, parents)
				parents.append(i)

	def dfs(self, v):
		visited = [False] * (max(self.adj_list) + 1)
		parents = [v]
		self.dfsUTIL(v, visited, parents)
		return len(parents)

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def seive_primes(n):
	flag = [0] * (n + 10)
	flag[1] = flag[0] = 1
	i = 2
	while i * i <= n + 1:
		if flag[i] == 0:
			j = i * i
			while j <= n + 1:
				flag[j] = 1
				j += i
		i += 1
	return flag

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def alphabates():
	return 'abcdefghijklmnopqrstuvwxyz'

def binary_search(ls, n, flag):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = (low + hi) // 2
		if ls[mid] == flag:
			return mid
		elif ls[mid] > flag:
			hi = mid - 1
		else:
			low = mid + 1
	return -1

def qdrt(x, a, b, c):
	return a * x * x + b * x + c

def inp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	(n, x) = mult_inp()
	if n <= 2:
		print(1)
		continue
	n -= 2
	print(math.ceil(n / x) + 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		rom = (n - 2) // x
		rem = (n - 2) % x
		if rem == 0:
			print(rom + 1)
		else:
			print(rom + 2)


def function(n, x):
	if n == 1 or n == 2:
		return 1
	x1 = x
	total = 0
	for i in range(10 ** 4):
		total += 1
		if i == 0:
			x += 2
		if i != 0:
			x += x1
		if n in [*range(1, x + 1)]:
			total += 1
			return total
			break
t = int(input())
for k1 in range(t):
	(n, x) = map(int, input().rstrip().split())
	print(function(n, x))


def solve(m, k):
	if m == 1:
		return 1
	if m == 2:
		return 1
	m -= 2
	if m % k == 0:
		return m // k + 1
	return m // k + 2
m = int(input())
for i in range(m):
	(k, m) = map(int, input().split(' '))
	print(solve(k, m))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
from math import ceil
for _ in range(int(input()) if True else 1):
	(n, k) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print(1 + ceil((n - 2) / k))


def petya(n, x):
	if n <= 2:
		return 1
	i = 2
	while True:
		if n >= (i - 2) * x + 3 and n <= (i - 1) * x + 2:
			return i
		i += 1
cases = int(input(''))
i = 0
while i < cases:
	i += 1
	s = str.split(input(''))
	(n, x) = (int(s[0]), int(s[1]))
	print(petya(n, x))


import math
t = int(input())
for case in range(t):
	(n, x) = [int(x) for x in input().split(' ')]
	if n <= 2:
		ans = 1
	else:
		n -= 2
		f = 2 + n // x
		if n % x == 0:
			f -= 1
		ans = f
	print(ans)


n = int(input())
while n:
	(x, y) = map(int, input().split())
	if x <= 2:
		print('1')
	elif (x - 2) % y == 0:
		print((x - 2) // y + 1)
	else:
		print((x - 2) // y + 2)
	n -= 1


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		n -= 2
		print((n + x - 1) // x + 1)


for _ in range(int(input())):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	lives = 0
	floor = 2
	ans = 1
	while floor < n:
		floor = floor + x
		ans = ans + 1
	print(ans)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	floor = 1
	if n == 1 or n == 2:
		print(floor)
	else:
		for i in range(n):
			floor += 1
			lower = (i - 1) * x + 3
			higher = i * x + 2
			if n <= higher and n >= lower:
				print(floor - 1)
				break
	t -= 1


import math
t = int(input())
i = 1
while i < t + 1:
	l = list(map(int, input().split()))
	n = l[0]
	x = l[1]
	if n <= 2:
		print('1')
	else:
		n = n - 2
		b = math.ceil(n / x)
		print(b + 1)
	i += 1


import math
t = int(input())
while t:
	t -= 1
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	if n <= 2:
		print('1')
		continue
	n -= 2
	print(math.ceil(n / k) + 1)


a = int(input())
for i in range(a):
	(n, x) = map(int, input().split())
	i = 0
	while True:
		if i * x + 3 > n:
			break
		i = i + 1
	print(i + 1)


def _flour_count(start, numbers):
	list = []
	for i in range(start, start + numbers):
		list.append(i)
	return list

def num_of_flour(p_num, totat_app):
	output = 2
	start = 3
	while p_num:
		if p_num in _flour_count(start, totat_app):
			return output
		else:
			start = start + totat_app
			output += 1
t = int(input())
if 1 <= t <= 1000:
	for i in range(t):
		nx = list(map(int, input().split()))
		n = nx[0]
		x = nx[1]
		if n >= 1 and x <= 1000:
			if n <= 2:
				print(1)
			else:
				print(num_of_flour(n, x))


import math, sys
t = int(sys.stdin.readline())
for i in range(t):
	(n, x) = map(int, sys.stdin.readline().split())
	if n <= 2:
		print(1)
	else:
		print(math.floor((n - 3) / x) + 2)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == 1 or a == 2:
		print('1')
	else:
		s = math.ceil((a - 2) / b + 1)
		print(s)


testcases = int(input())
for testcase in range(testcases):
	temparr = input()
	temparr = temparr.split()
	n = int(temparr[0])
	x = int(temparr[1])
	n -= 2
	floor = 1
	index = 1
	if n <= 0:
		print(1)
	else:
		while n:
			if n <= 0:
				break
			n -= x
			floor += 1
		print(floor)


def solve(n: int, x: int):
	apt = 2
	floor = 1
	while apt < n:
		apt += x
		floor += 1
	return floor
t = int(input())
answers = []
for _ in range(t):
	case = input().split(' ')
	for i in range(len(case)):
		case[i] = int(case[i])
	answers.append(solve(case[0], case[1]))
[print(ans) for ans in answers]


t = int(input())
floor = 0

def floor_num(n, x):
	if n <= 2:
		print(1)
	else:
		print((n - 3 + x) // x + 1)
for i in range(t):
	linia = input().rsplit(' ')
	(n, x) = (int(linia[0]), int(linia[1]))
	floor_num(n, x)


def call():
	(n, m) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print((n - 3) // m + 2)
for _ in range(int(input())):
	call()


t = int(input())
for i in range(t):
	n_x = input().split()
	n = int(n_x[0])
	x = int(n_x[1])
	if n == 1 or n == 2:
		print(1)
	else:
		ready = True
		count1 = 3
		floor = 2
		otro = 1
		while ready:
			range_apar = range(count1, otro * x + 2 + 1, 1)
			if n in range_apar:
				print(floor)
				ready = False
			else:
				floor += 1
				count1 = otro * x + 2
				otro += 1


t = int(input())
for i in range(t):
	(n, x) = [int(w) for w in input().split()]
	n -= 2
	a = 1
	while n > 0:
		n -= x
		a += 1
	print(a)


t = int(input())
for i in range(t):
	c = 0
	(a, b) = map(int, input().split())
	l = [2]
	for j in range(1000):
		l.append(b)
	for j in range(0, len(l)):
		c += l[j]
		if c >= a:
			print(j + 1)
			break


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	maxint = 10 ** 10
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def solve():
	(n, x) = num_input()
	if n == 1 or n == 2:
		print(1)
		return
	(start, end) = (3, x + 2)
	ans = 2
	while True:
		if n >= start and n <= end:
			print(ans)
			return
		start = end + 1
		end = ans * x + 2
		ans += 1
t = 1
t = int(input())
for _ in range(t):
	solve()


import sys
t = int(input())
li = []
for i in range(t):
	li.append(list(map(int, sys.stdin.readline().split())))
answer = []
for num in li:
	(n, x) = num
	apartment = [[], [1, 2], [3, x + 2]]
	for i in range(3, 1000):
		a = apartment[i - 1][1] + 1
		b = a + (x - 1)
		apartment.append([a, b])
	for i in range(1, 1000):
		if apartment[i][0] <= n <= apartment[i][1]:
			print(i)
			break


for testcase in range(int(input())):
	(n, x) = map(int, input().split())
	if n - 2 <= 0:
		print(1)
	else:
		count = 3
		ans = 1
		while count <= n:
			count += x
			ans += 1
		print(ans)


import math
t = int(input())
op = []
for i in range(t):
	a = list(map(int, input().split()))
	if a[0] < 3:
		op.append(1)
		continue
	else:
		b = math.ceil((a[0] - 2) / a[1])
		op.append(1 + b)
for i in op:
	print(i)


import sys
import math, bisect
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, x) = neo()
	t = 2
	Ans = 1
	while t < n:
		t += x
		Ans += 1
	print(Ans)


import sys
import math
t = int(sys.stdin.readline())
ans_arr = []
for i in range(t):
	[n, x] = [int(j) for j in sys.stdin.readline().split()]
	if n == 1 or n == 2:
		ans_arr.append(str(1))
	else:
		n -= 2
		ans = math.ceil(n / x)
		ans_arr.append(str(ans + 1))
print('\n'.join(ans_arr))


def solve(floor, x):
	res = 0
	if floor >= 2:
		floor -= 2
		res += 1
	res += floor // x
	res += 1 if floor % x > 0 else 0
	return res
res = []
t = int(input())
while t:
	line = input().split()
	floor = int(line[0])
	x = int(line[1])
	res.append(solve(floor, x))
	t -= 1
for r in res:
	print(r)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	floor = 1
	sa = 3
	la = 2
	while l[0] > la:
		floor += 1
		sa = la + 1
		la = sa + l[1] - 1
	print(floor)


def solution(n, x):
	if n <= 2:
		return 1
	cur = 2
	count = 1
	while cur < n:
		cur += x
		count += 1
	return count
testcase = int(input())
for i in range(0, testcase):
	inp = list(map(int, input().split()))
	(n, x) = (inp[0], inp[1])
	ans = solution(n, x)
	print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
mod2 = 998244353
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	(n, x) = inp()
	if n <= 2:
		ans = 1
	else:
		ans = 2
		temp = x
		while True:
			st = 3
			end = temp + 2
			if n >= st and n <= end:
				break
			else:
				ans += 1
				temp += x
	out(ans)


times = int(input())
for _ in range(times):
	(target, t) = map(int, input().split(' '))
	if target <= 2:
		print(1)
	else:
		rem = (target - 2) % t
		if rem != 0:
			print((target - 2) // t + 2)
		else:
			print((target - 2) // t + 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	floor = 1
	left_range = 1
	right_range = 2
	while True:
		if n >= left_range and n <= right_range:
			print(floor)
			break
		else:
			left_range = right_range + 1
			right_range = x * floor + 2
			floor += 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	elif n >= 3 and n <= x + 2:
		print(2)
	else:
		pref = 2
		last = x + 2
		f = 3
		while n < last + 1 or n > pref * x + 2:
			last = pref * x + 2
			pref = pref + 1
			f = f + 1
		print(f)


t = int(input())
for q in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		i = 1
		l = 3
		while True:
			i += 1
			if l <= n <= x * (i - 1) + 2:
				print(i)
				break
			l = 1 + (x * (i - 1) + 2)


import math
n = int(input())
apartment = [0] * n
no_of_floors = [0] * n
for i in range(n):
	temp = input()
	temp = temp.split(' ')
	apartment[i] = int(temp[0])
	no_of_floors[i] = int(temp[1])
result = 1
for i in range(n):
	if apartment[i] <= 2:
		result = 1
	else:
		apartment[i] = apartment[i] - 2
		temp = apartment[i] - apartment[i] % no_of_floors[i]
		result = result + int(temp / no_of_floors[i])
		temp = apartment[i] % no_of_floors[i]
		if temp > 0:
			result += 1
		while temp >= no_of_floors[i]:
			result += 1
			temp -= no_of_floors[i]
	print(result)
	result = 1


import math
T = int(input())
for I in range(0, T):
	X = input().split(' ')
	if int(X[0]) <= 2:
		print(1)
	else:
		print(math.ceil((int(X[0]) - 2) / int(X[1])) + 1)


t = int(input())
op = []
for i in range(t):
	(ap, x) = map(int, input().split())
	if ap <= 2:
		op.append(1)
	else:
		fl = 1
		ap -= 2
		while ap > 0:
			ap -= x
			fl += 1
		op.append(fl)
for i in op:
	print(i)


n = int(input())
apartments = [[int(i) for i in input().split()] for j in range(n)]
for case in apartments:
	if case[0] <= 2:
		print(1)
	elif (case[0] - 2) % case[1] == 0:
		print(1 + (case[0] - 2) // case[1])
	else:
		print(1 + (case[0] - 2) // case[1] + 1)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	if n <= 2:
		print(1)
		continue
	temp = 2
	count = 1
	while temp < n:
		count += 1
		temp += x
	print(count)


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, x) = inputnums()
	if n == 1 or n == 2:
		print(1)
		continue
	print((n - 2) // x + ((n - 2) % x != 0) + 1)


import math
t = int(input())
cases = []
while t > 0:
	cases.append([int(x) for x in input().split(' ')])
	t -= 1
for case in cases:
	if case[0] > 2:
		print(math.ceil((case[0] - 2) / case[1]) + 1)
	else:
		print(1)


t = int(input())
for test in range(t):
	(n, k) = [int(i) for i in input().split(' ')]
	if n == 1 or n == 2:
		res = 1
	else:
		res = (n - 3) // k + 2
	print(res)


import math
for _ in range(int(input())):
	(n, x) = [int(y) for y in input().split()]
	if n == 1 and x == 1:
		print(1)
	else:
		n = n - 2
		print(math.ceil(n / x) + 1)


import sys
import math as mt
import bisect
input = sys.stdin.readline
t = int(input())

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def solve():
	ans = max(0, (n - 2) // x)
	if (n - 2) % x != 0 and n - 2 > 0:
		ans += 1
	ans += 1
	return ans
for _ in range(t):
	(n, x) = map(int, input().split())
	print(solve())


import math

def ques1(n, x):
	if n <= 2:
		return 1
	if n <= x:
		return 2
	k = (n - 2) / x
	k1 = math.ceil(k)
	return 1 + k1
t = int(input())
for i in range(t):
	(n, x) = [int(i) for i in input().split()]
	ans = ques1(n, x)
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = [int(p) for p in input().split()]
	if n <= 2:
		print(1)
		continue
	curr = 2
	i = 1
	while curr < n:
		curr += x
		i += 1
	print(i)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		ct = 1
		apts = 3
		while apts <= n:
			ct += 1
			apts += x
		print(ct)


from sys import stdin, stdout
from math import gcd, sqrt, floor, ceil
from collections import Counter as cs
input = stdin.readline

def list_inp(x):
	return list(map(x, input().split()))

def map_inp(x):
	return map(x, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	q = 2
	cnt = 1
	while n > q:
		q += k
		cnt += 1
	print(cnt)


t = int(input())
b = [0] * t
for i in range(t):
	d = 1
	(n, x) = map(int, input().split())
	n -= 2
	while n > 0:
		n -= x
		d += 1
	b[i] = d
for i in range(t):
	print(b[i])


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	floorNumber = 1
	apartmentEnd = 2
	if n == 1 or n == 2:
		print(floorNumber)
	else:
		while n > apartmentEnd:
			apartmentEnd += x
			floorNumber += 1
		print(floorNumber)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		t = t - 1
		continue
	else:
		for i in range(1, 1000):
			if i * x + 2 >= n:
				print(i + 1)
				break
	t = t - 1


T = int(input())

def solve():
	(N, X) = list(map(int, input().split()))
	if N == 1 or N == 2:
		print(1)
	else:
		floors = (N - 2) // X
		if (N - 2) % X == 0:
			print(1 + floors)
		else:
			print(2 + floors)
for i in range(T):
	solve()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = -1
	r = n
	while l + 1 < r:
		m = (r + l) // 2
		if m * x + 2 >= n:
			r = m
		else:
			l = m
	print(r + 1)


t = int(input())
n = []
x = []
for i in range(0, t):
	(a, b) = input().split()
	n.append(int(a))
	x.append(int(b))
for i in range(0, t):
	if n[i] == 1 or n[i] == 2:
		print(1)
		continue
	else:
		f = (n[i] - 2) // x[i]
		fl = f * x[i] + 2
		while fl < n[i]:
			f += 1
			fl = f * x[i] + 2
		print(f + 1)


k_t = int(input(''))
t = []
for i in range(k_t):
	t += map(int, input('').split())
for i in range(0, k_t * 2, 2):
	if t[i] <= 2:
		print(1)
	elif (t[i] - 2) % t[i + 1]:
		print((t[i] - 2) // t[i + 1] + 2)
	else:
		print((t[i] - 2) // t[i + 1] + 1)


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	(n, x) = mi()
	if n <= 2:
		print(1)
	else:
		print(1 + (n - 2) // x if (n - 2) % x == 0 else 2 + (n - 2) // x)


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def solve():
	(n, x) = IP()
	if n <= 2:
		print(1)
		return
	else:
		last = 2
		floor = 2
		while True:
			start = last + 1
			last = x * (floor - 1) + 2
			if n >= start and n <= last:
				print(floor)
				return
			floor += 1
	return
t = II()
for i in range(t):
	solve()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	floor = 2
	if n <= 2:
		print(1)
		continue
	start = 3
	end = x + 2
	for i in range(n):
		if n >= start and n <= end:
			print(floor)
			break
		else:
			start += x
			end += x
			floor += 1


def do():
	q = int(input())
	for _ in range(q):
		(x, n) = map(int, input().split())
		if x == 1 or x == 2:
			print(1)
			continue
		import math
		res = 2
		x -= 3
		import math
		res += x // n
		print(res)
do()

def resolve():
	from pprint import pprint
	q = int(input())
	for _ in range(q):
		s = input()
		n = int(input())
		(n, k) = map(int, input().split())
		dat = list(map(int, input().split()))
	dat = [1, 2, 3]
	print(' '.join(list(map(str, res))))
	pass
	import math
	math.ceil(1.2)
	math.floor(1.2)
	round(1.2, 3)


from math import ceil
t = int(input())
s = []
for _ in range(t):
	(a, b) = map(int, input().split())
	if a > 2:
		s.append(ceil((a - 2) / b) + 1)
	else:
		s.append(1)
for i in s:
	print(i)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n < 3:
		print(1)
		continue
	n -= 2
	out = n // x + 1
	if n % x != 0:
		out += 1
	print(out)


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		print(1)
		continue
	ans = int(math.ceil((n - 2) / x))
	print(ans + 1)


def solve(n, x):
	if n < 3:
		return 1
	first_flat_on_floor = 3
	floor = 2
	while n > first_flat_on_floor + x - 1:
		first_flat_on_floor += x
		floor += 1
	return floor
for _ in range(int(input().strip())):
	(n, x) = map(int, input().strip().split())
	print(solve(n, x))


for x in range(int(input())):
	(n, t) = map(int, input().split())
	c = 1
	d = 2
	while d <= n:
		if d != n:
			c = c + 1
		d = d + t
	print(c)


u = int(input(''))
for i in range(u):
	count = 1
	x = list(input('').split(' '))
	floor = int(x[0]) - 2
	while floor > 0:
		floor = floor - int(x[1])
		count += 1
	print(count)


import math
t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	if a <= 2:
		print(1)
	else:
		a = a - 2
		print(1 + math.ceil(a / b))
	t = t - 1


for x in range(int(input())):
	(n, x) = map(int, input().split())
	floor = 1
	if n < 3:
		print(1)
	else:
		aps = n - 2
		while aps > x * floor:
			floor += 1
		print(floor + 1)


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	q = 1
	if n >= 2:
		n -= 2
	else:
		print(q)
		continue
	if n % k == 0:
		print(q + n // k)
	else:
		print(q + 1 + n // k)


t = int(input())
for j in range(t):
	(n, m) = map(int, input().strip().split())
	floor_number = 1
	count = 1
	if n <= 2:
		print(floor_number)
	else:
		while count <= n - 2:
			floor_number += 1
			count = count + m
		print(floor_number)


t = int(input())
floors = []
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= 2:
		floor = 1
	elif (n - 2) % x == 0:
		floor = (n - 2) // x + 1
	else:
		floor = (n - 2) // x + 2
	floors.append(floor)
for floor in floors:
	print(floor)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	ret = -1
	for floor in range(2, 1001):
		if n < 3 + (floor - 2) * x:
			ret = floor - 1
			break
	print(ret)


import sys
t = int(input().strip())
for a0 in range(t):
	l1 = [int(i) for i in input().split()]
	n = l1[0]
	x = l1[1]
	c = 2
	if n == 1 or n == 2:
		print(1)
	else:
		c += (n - 2) // x
		if (n - 2) % x == 0:
			c -= 1
		print(c)


import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		num = (n - 2) / x
		if num == int(num):
			print(int(num) + 1)
		else:
			print(int(num) + 2)


def main(n, x):
	if n <= 2:
		return 1
	y = (n - 2) % x
	z = int((n - 2) / x)
	if y != 0:
		return z + 2
	else:
		return z + 1
t = int(input())
for t_itr in range(t):
	nx = list(map(int, input().rstrip().split()))
	n = nx[0]
	x = nx[1]
	res = main(n, x)
	print(res)


from math import ceil
for t in range(0, int(input())):
	(n, x) = [int(q) for q in input().split()]
	if n < 3:
		print(1)
	else:
		print(ceil((n - 2) / x) + 1)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
mod = 998244353
INF = float('inf')
for t in range(int(data())):
	(n, x) = mdata()
	if n < 3:
		out(1)
		continue
	n -= 2
	k = math.ceil(n / x)
	out(k + 1)


T = int(input())
while T:
	(n, x) = map(int, input().split())
	if n <= 2:
		print('1')
	else:
		n -= 2
		f = 1
		while n > 0:
			n -= x
			f += 1
		print(f)
	T -= 1


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))
t = inp()
for i in range(t):
	inp_line = inlt()
	n = inp_line[0]
	x = inp_line[1]
	res = 0
	if n <= 2:
		res = 1
	elif n <= x:
		res = 2
	else:
		n -= 2
		res += 1
		if n % x > 0:
			res += 1
		res += n / x
	print(int(res))


a = int(input())
for i in range(0, a):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	if n < 3:
		print(1)
	elif (n - 2) % k != 0:
		print((n - 2) // k + 2)
	else:
		print((n - 2) // k + 1)


t = int(input())
for _ in range(t):
	floor = 1
	(n, x) = [int(i) for i in input().split()]
	if n > 2:
		floor = (n - 2) // x + 1
		if (n - 2) % x != 0:
			floor += 1
	print(floor)


import math
for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split(' ')]
	if a <= 2:
		print(1)
	else:
		print((a - 3) // b + 2)


import math
n = int(input())
x = []
for i in range(n):
	s = input().split(' ')
	nums = list(map(int, s))
	x.append(nums)
for i in x:
	if i[0] <= 2:
		print('1')
	else:
		print(math.ceil((i[0] - 2) / i[1]) + 1)


testcases = int(input())
import math
for testcase in range(testcases):
	temparr = input()
	temparr = temparr.split()
	n = int(temparr[0])
	k = int(temparr[1])
	n -= 2
	ans = 0
	if n <= 0:
		print(1)
		continue
	else:
		ans += math.ceil(n / k)
		print(ans + 1)


k = int(input())
for i in range(1, k + 1):
	(n, x) = map(int, input().split())
	e = 0
	if n == 1 or n == 2:
		e = 1
	else:
		m = n - 3
		e = m // x + 2
	print(e)


t = int(input())
while t:
	user_input = list(map(int, input().split()))
	if user_input[0] <= 2:
		print(1)
	else:
		user_input[0] -= 2
		floor = user_input[0] // user_input[1]
		while floor * user_input[1] < user_input[0]:
			floor += 1
		print(floor + 1)
	t -= 1


def solve(n, x):
	if n < 3:
		return 1
	res = 1
	n -= 2
	q = n // x
	r = n % x
	res += q
	if r:
		res += 1
	return res
t = int(input())
for i in range(t):
	_ = input().split()
	(n, x) = (int(_[0]), int(_[1]))
	print(solve(n, x))


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
		continue
	for i in range(n):
		if n >= i * x + 3 and n <= x * (i + 1) + 2:
			print(i + 2)
			break


import math

def solve():
	(n, x) = [int(x) for x in input().split()]
	if n < 3:
		print(1)
		return 0
	n = n - 2
	n = math.ceil(n / x)
	print(n + 1)
	return 0
t = int(input())
for _ in range(t):
	solve()


t = int(input())
while t:
	(n, x) = map(int, input().split())
	ans = (n - 2) // x if n - 2 > 0 else 0
	ans = ans + 1 if (n - 2) % x != 0 and n - 2 > 0 else ans
	print(ans + 1)
	t -= 1


def f(n, k):
	if n <= 0:
		return 1
	s = n // k
	if n % k == 0:
		return s + 1
	return s + 2
T = int(input())
while T:
	(n, k) = map(int, input().split())
	n = n - 2
	print(f(n, k))
	T -= 1


from math import gcd
for _ in range(int(input())):
	(n, x) = list(map(int, input().split(' ')))
	count = 1
	val = 2
	while val < n:
		val += x
		count += 1
	print(count)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	n -= 2
	count = 1
	if n > 0 and n % x == 0:
		count += n // x
	elif n > 0 and n % x != 0:
		count += n // x + 1
	print(count)


import sys
from sys import stdin, stdout
ipi = lambda : int(stdin.readline())
ipil = lambda : map(int, stdin.readline().split())
ipf = lambda : float(stdin.readline())
ipfl = lambda : map(float, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
outl = lambda x: print(*x)
T = ipi()
for _ in range(T):
	(n, x) = ipil()
	if n < 3:
		print(1)
	else:
		print(2 + (n - 3) // x)


t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	if a == 1 or a == 2:
		print(1)
	else:
		a = a + b - 1 - 2
		ans = a // b
		print(ans + 1)


t = int(input())
while t > 0:
	t = t - 1
	aux = input()
	n = int(aux.split()[0])
	x = int(aux.split()[1])
	if n < 3:
		print(1)
		continue
	n -= 2
	print(n // x + (n % x > 0) + 1)


import math
for i in range(int(input())):
	(n, m) = map(int, input().split())
	if n <= 2:
		print(1)
	else:
		print((n - 3) // m + 2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1 or n == 2:
		print(1)
	else:
		j = 1
		temp = 0
		for i in range(3, n + 1, x):
			if n in range(i, x + i):
				temp = j + 1
			j += 1
		print(temp)


import math
t = int(input())
while t != 0:
	(N, X) = input().split()
	n = int(N) - 2
	x = int(X)
	if n >= 0:
		a = math.ceil(n / x)
		print(a + 1)
	else:
		print(1)
	t -= 1