Vova plans to go to the conference by train. Initially, the train is at the point $1$ and the destination point of the path is the point $L$. The speed of the train is $1$ length unit per minute (i.e. at the first minute the train is at the point $1$, at the second minute — at the point $2$ and so on).

There are lanterns on the path. They are placed at the points with coordinates divisible by $v$ (i.e. the first lantern is at the point $v$, the second is at the point $2v$ and so on).

There is also exactly one standing train which occupies all the points from $l$ to $r$ inclusive.

Vova can see the lantern at the point $p$ if $p$ is divisible by $v$ and there is no standing train at this position ($p \not\in [l; r]$). Thus, if the point with the lantern is one of the points covered by the standing train, Vova can't see this lantern.

Your problem is to say the number of lanterns Vova will see during the path. Vova plans to go to $t$ different conferences, so you should answer $t$ independent queries.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) — the number of queries.

Then $t$ lines follow. The $i$-th line contains four integers $L_i, v_i, l_i, r_i$ ($1 \le L, v \le 10^9$, $1 \le l \le r \le L$) — destination point of the $i$-th path, the period of the lantern appearance and the segment occupied by the standing train.


-----Output-----

Print $t$ lines. The $i$-th line should contain one integer — the answer for the $i$-th query.


-----Example-----
Input
4
10 2 3 7
100 51 51 51
1234 1 100 199
1000000000 1 1 1000000000

Output
3
0
1134
0



-----Note-----

For the first example query, the answer is $3$. There are lanterns at positions $2$, $4$, $6$, $8$ and $10$, but Vova didn't see the lanterns at positions $4$ and $6$ because of the standing train.

For the second example query, the answer is $0$ because the only lantern is at the point $51$ and there is also a standing train at this point.

For the third example query, the answer is $1134$ because there are $1234$ lanterns, but Vova didn't see the lanterns from the position $100$ to the position $199$ inclusive.

For the fourth example query, the answer is $0$ because the standing train covers the whole path.

Difficulty: EASY

Solutions:
T = int(input())
for _ in range(T):
	(N, V, L, R) = map(int, input().split())
	cnt = 0
	cnt1 = (L - 1) // V
	cnt2 = N // V - R // V
	print(cnt1 + cnt2)


for Y in range(int(input())):
	(L, v, l, r) = [int(x) for x in input().split()]
	print(L // v + (l - 1) // v - r // v)


n = int(input())
for i in range(n):
	(L, v, l, r) = map(int, input().split())
	count = L // v - (r // v - (l - 1) // v)
	print(count)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
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 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 main():
	t = I()
	aa = [LI() for _ in range(t)]
	rr = []
	for (a, b, l, r) in aa:
		t = a // b
		if l % b > 0:
			l += b - l % b
		if l <= r:
			t -= 1
			t -= (r - l) // b
		rr.append(t)
	return '\n'.join(map(str, rr))
print(main())


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split(' '))
	d = r if v >= l else r - l + (v if l % v == 0 else l % v)
	print(L // v - d // v)


t = int(input())
while t > 0:
	(L, v, l, r) = map(int, input().split())
	if r % v:
		r += v - r % v
		if r > L:
			print(int((l - 1) / v))
		else:
			print(int((l - 1) / v) + int((L - r) / v) + 1)
	else:
		print(int((l - 1) / v) + int((L - r) / v))
	t -= 1


from sys import stdin, stdout
t = int(stdin.readline())
for i in range(t):
	(L, v, l, r) = [int(x) for x in stdin.readline().rstrip().split(' ')]
	a1 = l // v + (0 if l % v == 0 else 1)
	an = r // v
	n = an - a1 + 1
	count = L // v - n
	stdout.write(str(count))
	if i != t - 1:
		stdout.write('\n')


def solve(L, v, l, r):
	return L // v - r // v + (l - 1) // v
ans = []
n = int(input())
for i in range(n):
	(L, v, l, r) = map(int, input().split(' '))
	ans.append(solve(L, v, l, r))
for a in ans:
	print(a)


import math
t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	lant = L // v
	hidf = math.ceil(l / v)
	hidl = math.floor(r / v)
	hid = hidl - hidf + 1
	print(lant - hid)


t = int(input())
while t:
	t -= 1
	(d, v, l, r) = map(int, input().rstrip().split(' '))
	if l % v:
		l1 = l + v - l % v
	else:
		l1 = l
	r1 = r - r % v
	if r1 not in range(l, r + 1):
		r1 = 0
		l1 = 0
	if r1 == 0:
		total = d // v
	else:
		total = d // v - ((r1 - l1) // v + 1)
	print(total)


import sys
import numbers
import decimal
ks = int(input(''))
while ks > 0:
	str = input()
	arr = str.split()
	L = int(arr[0])
	v = int(arr[1])
	l = int(arr[2])
	r = int(arr[3])
	t = int(L / v)
	fp = int((l - 1) / v)
	fsp = int(r / v)
	t -= fsp - fp
	print(t)
	ks = ks - 1


t = int(input())
for _ in range(t):
	(dest, period, l, r) = list(map(int, input().strip().split()))
	lights = 0
	if l > dest:
		print(int(dest / period))
	else:
		lights += int((l - 1) / period)
		if r < dest:
			dest -= int(r / period) * period
			lights += int(dest / period)
		print(lights)


for _ in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	tot = L // v
	first_not_seen = (l - 1) // v + 1
	last_not_seen = r // v
	print(tot - (last_not_seen - first_not_seen + 1))


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	ans = L // v
	ans -= r // v
	ans += (l - 1) // v
	print(ans)


def count_lanterns(destination, lantern_frequency, l, r):
	nlantern = destination // lantern_frequency
	(nl, nl_mod) = divmod(l, lantern_frequency)
	first_left_lantern = nl * lantern_frequency + (nl_mod != 0) * lantern_frequency
	(nr, nl_mod) = divmod(r, lantern_frequency)
	right_first_lantern = nr * lantern_frequency
	hidden_lanterns = (right_first_lantern - first_left_lantern) // lantern_frequency + 1
	return nlantern - hidden_lanterns
t = int(input())
for i in range(t):
	(L, v, l, r) = [int(x) for x in input().split()]
	result = count_lanterns(L, v, l, r)
	print(result)


n = int(input())
for i in range(n):
	(l, v, x, y) = [int(i) for i in input().split()]
	ans = l // v
	aa = y // v
	x = x - 1
	bb = x // v
	ans = ans - (aa - bb)
	print(ans)


t = int(input())
for _ in range(t):
	(L, v, l, r) = map(int, input().split())
	print(L // v - r // v + (l - 1) // v)


t = int(input())
for z in range(t):
	l = list(map(int, input().split()))
	result = (l[2] - 1) // l[1] + l[0] // l[1] - l[3] // l[1]
	print(result)


amount = int(input())

def count_lamps(l, v, left, right):
	all_lamps = l // v
	start = left // v * v
	if left % v == 0:
		all_lamps -= (right - left) // v + 1
	else:
		start += v
		all_lamps -= (right - start) // v + 1
	return all_lamps
for i in range(amount):
	(l, v, left, right) = [int(s) for s in input().split()]
	print(count_lamps(l, v, left, right))


import math

def io_main():
	for _ in range(int(input())):
		(L, v, l, r) = map(int, input().split())
		num_seen = L // v
		block_start = int(math.ceil(l / v))
		block_end = int(math.floor(r / v))
		num_seen -= block_end - block_start + 1
		print(num_seen)
io_main()


def vova_and_train():
	ans = destination_point // period_of_lantern - (segment_occupied_2 // period_of_lantern - (segment_occupied_1 - 1) / period_of_lantern)
	return int(ans)
num_of_testcases = int(input())
for _ in range(num_of_testcases):
	(destination_point, period_of_lantern, segment_occupied_1, segment_occupied_2) = map(int, input().split())
	print(vova_and_train())


def main():

	def cnts(x, y):
		return x // y
	T = int(input())
	for i in range(T):
		(L, v, l, r) = map(int, input().split())
		print(cnts(L, v) - (cnts(r, v) - cnts(l - 1, v)))
main()


for _ in range(int(input())):
	(n, d, s, e) = map(int, input().split())
	n1 = n // d
	ch = 0
	cn = s % d
	if cn == 0:
		ch = s
	else:
		ch = s - cn + d
	tt1 = (e - ch) // d
	print(n1 - tt1 - 1)


def calc_count(info):
	L = info[0]
	v = info[1]
	l = info[2]
	r = info[3]
	return L // v - (r // v - (l - 1) // v)
t = None
data = list()
seen = list()
t = int(input().strip())
for i in range(t):
	data.append(tuple(map(int, input().strip().split())))
	seen.append(calc_count(data.pop()))
for item in seen:
	print(item)


t = int(input())
for i in range(t):
	(l, v, l1, r) = map(int, input().split())
	if l1 % v == 0:
		x1 = l1 // v - 1
	else:
		x1 = l1 // v
	x2 = r // v
	x3 = l // v
	print(x1 + x3 - x2)


for _ in [0] * int(input()):
	(L, v, l, r) = map(int, input().split())
	print(L // v - r // v + (l - 1) // v)


import math
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	lan = a // b
	ans = 0
	kk = math.ceil(c / b) * b
	if kk <= d:
		ans = abs(d - kk) // b + 1
	print(lan - ans)


q = int(input())
for i in range(q):
	(d, v, L, R) = map(int, input().split())
	print(d // v + (L - 1) // v - R // v)


i = int(input())
ans = []
for n in range(i):
	(L, v, l, r) = map(int, input().split())
	ans.append((l - 1) // v + L // v - r // v)
for i in ans:
	print(i)


t = int(input())
a = [[int(j) for j in input().split()] for i in range(t)]
for i in range(t):
	for j in range(1):
		b = a[i][0] // a[i][1] - (a[i][3] // a[i][1] - (a[i][2] - 1) // a[i][1])
		print(b)


t = int(input())
for i in range(t):
	(L, v, l, r) = list(map(int, input().split()))
	q = L // v
	l1 = (l + v - 1) // v
	r1 = r // v
	print(q - r1 + l1 - 1)


import math
for i in range(int(input())):
	(d, v, l, r) = map(int, input().split())
	print(math.floor(d / v) - math.floor(r / v) + math.floor((l - 1) / v))


t = int(input())
while t:
	(L, v, l, r) = map(int, input().split())
	print(L // v - r // v + (l - 1) // v)
	t -= 1


arr = []
for i in range(int(input())):
	arr.append([int(i) for i in input().split()])
for i in arr:
	(l, v, nachalo, konec) = i
	print(int((nachalo - 0.5) // v + (l // v - konec // v)))


import collections

def solve(M, v, l, r):
	total = M // v
	from1ToL = (l - 1) // v
	from1ToR = r // v
	return from1ToL + total - from1ToR
t = int(input().strip())
for i in range(t):
	[M, v, l, r] = list(map(int, input().strip().split()))
	print(solve(M, v, l, r))


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	print(a // b - d // b + (c - 1) // b)


t = int(input())
for i in range(t):
	k = 0
	(L, v, l, r) = map(int, input().split())
	if l % v == 0:
		k += (l - 1) // v
	else:
		k += (l - l % v) // v
	if L - r >= v and r % v == 0:
		k += (L - L % v - (r - r % v + v)) // v + 1
	else:
		k += (L - (r - r % v)) // v
	print(k)


import math
n = int(input())
for k in range(n):
	a = [int(q) for q in input().strip().split()]
	b = math.floor(a[3] / a[1])
	c = math.floor(a[2] / a[1])
	if int(a[2]) % int(a[1]) == 0:
		c -= 1
	print(int(a[0] / a[1]) - b + c)


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	blocked = r // v - (l - 1) // v
	seen = L // v - blocked
	print(seen)


for _ in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	count = 0
	a = int(L / v)
	b = int((l - 1) / v)
	c = int(r / v)
	print(a + b - c)


Times = int(input())
while Times > 0:
	Times -= 1
	lis = input().split()
	for it in range(0, 4):
		lis[it] = int(lis[it])
	ear = lis[3] // lis[1] - (lis[2] - 1) // lis[1]
	print('%d' % (lis[0] // lis[1] - ear))


from math import floor
n = int(input())
ans = []
for i in range(0, n):
	(L, v, l, r) = map(int, input().split())
	all_lantern = floor(L / v)
	hidden_lantern = floor(r / v) - floor((l - 1) / v)
	ans.append(str(all_lantern - hidden_lantern))
print('\n'.join(ans))


for _ in range(int(input())):
	(l, r, a, b) = map(int, input().split())
	q = l // r
	t = 0
	if a % r == 0:
		t = 1
	t = t + b // r - a // r
	print(q - t)


import sys
nbreq = int(sys.stdin.readline())
for i in range(nbreq):
	(goal, lantern, l, r) = map(int, sys.stdin.readline().split())
	total = goal // lantern - r // lantern + (l - 1) // lantern
	print(total)


t = [int(val) for val in input().split()][0]
for i in range(t):
	(L, v, l, r) = [int(val) for val in input().split()]
	lanterns = L // v
	ld = l // v
	rd = r // v
	st = rd - ld
	if l % v == 0:
		st += 1
	print(lanterns - st)


testCount = int(input())
while testCount > 0:
	testCount -= 1
	(L, v, l, r) = map(int, input().split(' '))
	ans = L // v - (r // v - (l - 1) // v)
	print(ans)


t = int(input())
for i in range(t):
	(ln, v, l, r) = map(int, input().split())
	n = ln // v - r // v + (l - 1) // v
	print(n)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	x = a // b
	y = d // b
	c = c - 1
	z = c // b
	x = x - (y - z)
	print(x)


t = input()
for line in range(int(t)):
	numbers = input().split()
	L = int(numbers[0])
	v = int(numbers[1])
	l = int(numbers[2])
	r = int(numbers[3])
	totalLanterns = L // v
	trainLanterns = r // v - (l - 1) // v
	p = totalLanterns - trainLanterns
	print(p)


for _ in range(int(input())):
	(l, v, a, b) = map(int, input().split())
	print(l // v if b < (a + v - 1) // v * v else l // v - 1 - (b - (a + v - 1) // v * v) // v)


t = int(input())
ans = [0] * t
for k in range(t):
	(l, v, i, r) = list(map(int, input().split()))
	i -= 1
	ally = l // v
	blind = r // v
	seen = i // v
	ans[k] = ally - blind + seen
for i in range(t):
	print(ans[i])


while True:
	try:
		t = int(input())
	except:
		break
	for i in range(t):
		count = 0
		(L, v, l, r) = map(int, input().split())
		sum = L // v
		ll = l // v
		lr = r // v
		if l == r and l % v == 0:
			sum = sum - (lr - ll) - 1
		elif l % v == 0:
			sum = sum - (lr - ll)
			sum = sum - 1
		else:
			sum = sum - (lr - ll)
		if sum <= 0:
			sum = 0
		print(sum)


t = int(input())
for t in range(t):
	(L, v, l, r) = map(int, input().split())
	otv = L // v - r // v + l // v
	if l % v == 0:
		print(otv - 1)
	else:
		print(otv)


t = int(input(''))
for i in range(0, t):
	a = list(map(int, input().split()))
	l = (a[2] - 1) // a[1]
	m = a[0] // a[1] - a[3] // a[1]
	print(m + l)


for x1 in range(int(input())):
	(length, multi, l, r) = map(int, input().strip().split()[:4])
	print(length // multi - (r // multi - (l - 1) // multi))


tc = int(input())
for i in range(tc):
	x = input().split(' ')
	L = int(x[0])
	v = int(x[1])
	l = int(x[2])
	r = int(x[3])
	print(L // v - r // v + (l - 1) // v)


T = int(input())
for q in range(T):
	(L, v, l, r) = map(int, input().strip().split())
	if l % v == 0:
		j = -1 + l // v
	else:
		j = l // v
	print(L // v - (r // v - j))


n = int(input())
for i in range(n):
	(L, v, l, r) = map(int, input().split())
	l_mod = l % v
	if l % v != 0:
		l += v - l_mod
	if r % v != 0:
		r -= r % v
	dist = 0
	if l <= r:
		dist = (r - l) // v + 1
	print(L // v - dist)


def solve():
	(L, v, l, r) = map(int, input().split())

	def div_by(a, b, k):
		if a == 1:
			return b // k
		return div_by(1, b, k) - div_by(1, a - 1, k)
	res = div_by(1, L, v)
	res -= div_by(l, r, v)
	print(res)
t = int(input())
for _ in range(t):
	solve()


T = int(input())
for _ in range(T):
	(N, V, L, R) = list(map(int, input().split()))
	n = N // V
	m1 = (L - 1) // V
	m2 = R // V
	print(n - (m2 - m1))


n = int(input())
while n:
	(a, b, c, d) = map(int, input().split())
	ans = a // b
	if c % b != 0:
		c = c + b - c % b
	if d % b != 0:
		d = d - d % b
	print(ans - 1 - (d - c) // b)
	n -= 1


a = int(input())
for i in range(a):
	(b, c, d, f) = list(map(int, input().split()))
	print(b // c - (f // c - (d - 1) // c))


for i in range(int(input())):
	tmp = input().split()
	ans = int(int(tmp[0]) / int(tmp[1]))
	ans -= int(int(tmp[3]) / int(tmp[1])) - int((int(tmp[2]) - 1) / int(tmp[1]))
	print(ans)


from sys import stdin, stdout
T = int(stdin.readline())
while T > 0:
	(L, v, l, r) = map(int, stdin.readline().split())
	if l % v == 0:
		z = L // v - (r // v - l // v) - 1
		print(z)
	else:
		z = L // v - (r // v - l // v)
		print(z)
	T = T - 1


n = int(input())
for i in range(n):
	(L, v, l, r) = map(int, input().split())
	c = L // v
	minus = 0
	f = l // v
	s = r // v
	minus = s - f
	if l % v == 0:
		minus += 1
	print(c - minus)


import sys, math
q = int(sys.stdin.readline())
for i in range(q):
	query = sys.stdin.readline()
	(L, v, l, r) = list(map(int, query.split(' ')))
	ll = v
	rr = L // v * v
	lr = (int(math.ceil(l / v)) - 1) * v
	rl = (r // v + 1) * v
	left = (lr - ll) // v + 1 if ll <= lr else 0
	right = (rr - rl) // v + 1 if rl <= rr else 0
	print(left + right)


t = int(input().strip())
for i in range(t):
	(L, v, l, r) = [int(i) for i in input().split()]
	a = (l - 1) // v
	b = (L - (r - r % v)) // v
	print(a + b)


for _ in range(int(input())):
	(L, v, l, r) = list(map(int, input().strip().split()))
	ans = L // v
	if l % v == 0:
		ans -= (r - l) // v + 1
	else:
		ans -= (r - (l // v + 1) * v) // v + 1
	print(ans)


for q in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	total = L // v
	if l % v == 0:
		l = l // v
	else:
		l = l // v + 1
	r = r // v
	total -= r - l + 1
	print(total)


t = int(input())
for i in range(t):
	(d, v, l, r) = [int(x) for x in input().split()]
	num = d // v
	if l % v == 0:
		l = l // v
	else:
		l += v - l % v
		l = l // v
	r = r // v
	num -= r - l + 1
	print(num)


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	ll = (l - 1) // v
	rr = L // v - r // v
	res = ll + rr
	print(res)


t = int(input())
for i in range(0, t):
	(L, v, l, r) = map(int, input().split())
	a = int(L / v)
	b = int(r / v)
	c = int((l - 1) / v)
	s = a - b + c
	print(s)


import sys

def rint():
	return map(int, sys.stdin.readline().split())
t = int(input())
for i in range(t):
	(L, v, l, r) = rint()
	ans = L // v - (r // v - (l - 1) // v)
	print(ans)


k = int(input())
while k:
	(L, V, L2, R) = map(int, input().split())
	res = L // V - (R // V - (L2 - 1) // V)
	k -= 1
	print(res)


t = int(input())
for i in range(0, t):
	a = list(map(int, input().split()))
	L = a[0]
	v = a[1]
	l = a[2]
	r = a[3]
	p = []
	print(L // v - r // v + (l - 1) // v)


t = int(input())
for t in range(t):
	(L, v, left, right) = list(map(int, input().split()))
	tmp1 = (left - 1) // v
	tmp2 = right // v
	tmp2 = L // v - tmp2
	print(tmp1 + tmp2)


t = int(input())
while t:
	t -= 1
	(l, v, x, y) = map(int, input().split())
	re = l // v
	df = y // v - (x - 1) // v
	print(re - df)


t = int(input())

def query(input):
	(L, v, l, r) = map(int, input.split())
	lantern = L // v
	for i in range(l // v, l // v + 2):
		if v * i in range(l, r + 1):
			m = v * i
			covered = (r - m) // v + 1 if (r - m) % v != 0 or ((r - m) % v == 0 and r % v == 0) else (r - m) // v
			break
		else:
			covered = 0
	return lantern - covered
for i in range(t):
	print(query(input()))


t = int(input())
for i in range(t):
	(L, v, l, r) = (int(x) for x in input().split())
	c = L // v - r // v + (l - 1) // v
	print(c)


t = int(input())
for i in range(t):
	ls = [int(x) for x in input().strip().split()]
	(L, v, l, r) = (ls[0], ls[1], ls[2], ls[3])
	l = l - 1
	print(L // v - r // v + l // v)


for i in range(int(input())):
	(x, y, l, r) = map(int, input().split())
	print((l - 1) // y + x // y - r // y)


t = int(input())
for i in range(t):
	(L, u, l, r) = map(int, input().split())
	d = 0
	print(L // u - (r // u - (l - 1) // u))


k = int(input())
n = 0
while k > n:
	n = n + 1
	(L, v, l, r) = map(int, input().split())
	print(L // v - r // v + (l - 1) // v)


mas = []
for i in range(int(input())):
	mas.append([int(i) for i in input().split()])
for i in mas:
	print(int((i[2] - 0.5) // i[1] + (i[0] // i[1] - i[3] // i[1])))


n = int(input())
for q in range(n):
	(L, v, l, r) = list(map(int, input().split()))
	ac = L // v
	lc = l // v + (0 if l % v == 0 else 1)
	rc = r // v
	print(ac - (rc - lc + 1))


t = int(input())
for i in range(t):
	(l, v, li, r) = map(int, input().split())
	p = l // v - (r // v - (li - 1) // v)
	print(p)


n = int(input())
for i in range(n):
	(k, per, a, b) = map(int, input().split())
	sum = k // per
	a1 = (a - 1) // per
	b1 = (b - 1) // per
	if b % per == 0:
		b1 += 1
	print(sum - b1 + a1)


for _ in range(int(input())):
	(l, v, x, y) = map(int, input().split())
	print(l // v - (y // v - (x - 1) // v))


t = int(input())
for t_itr in range(t):
	pqrs = input().rstrip().split()
	p = int(pqrs[0])
	q = int(pqrs[1])
	r = int(pqrs[2])
	s = int(pqrs[3])
	lantern = p // q - s // q + (r - 1) // q
	print(lantern)


def countDiv(A, B, M):
	if A % M == 0:
		return B // M - A // M + 1
	return B // M - A // M
for i in range(int(input())):
	(n, m, l, r) = map(int, input().split())
	if l == 1 and r == n:
		print(0)
	else:
		print(countDiv(1, l - 1, m) + countDiv(r + 1, n, m))


import math

def get_input_list():
	return list(map(int, input().split()))
t = int(input())
data = []
for _ in range(t):
	data.append(get_input_list())
for i in data:
	(L, v, l, r) = i
	a = int((l - 1e-05) / v)
	b = math.floor((r + 1e-05) / v)
	c = int(L / v)
	print(a + c - b)


t = int(input())
for _ in range(t):
	(L, v, l, r) = [int(i) for i in input().split()]
	if L % v != 0:
		lastLantern = L - L % v
	else:
		lastLantern = L
	totalNoOfLanterns = lastLantern // v - v // v + 1
	if l % v != 0:
		firstLanternHidden = l + (v - l % v)
	else:
		firstLanternHidden = l
	if r % v != 0:
		lastLanternHidden = r - r % v
	else:
		lastLanternHidden = r
	hiddenLanterns = lastLanternHidden // v - firstLanternHidden // v + 1
	ans = totalNoOfLanterns - hiddenLanterns
	print(ans)


t = int(input())
for i in range(t):
	a = input()
	(L, v, l, r) = (int(a.split()[0]), int(a.split()[1]), int(a.split()[2]), int(a.split()[3]))
	x = 0
	x = L // v
	s = 0
	if l % v == 0:
		print(x + l // v - r // v - 1)
	else:
		print(x + l // v - r // v)


import math
t = int(input())
for _ in range(t):
	(L, v, l, r) = list(map(int, input().split()))
	n_lanterns = math.floor(L / v)
	s = 0
	total = math.floor(L / v)
	ll = math.floor((l - 1) / v)
	rr = math.floor(r / v)
	rplus = total - rr
	print(ll + rplus)


for i in range(int(input())):
	X = list(map(int, input().split()))
	print((X[2] - 1) // X[1] + X[0] // X[1] - X[3] // X[1])


t = int(input())
for _ in range(t):
	(L, v, l, r) = map(int, input().split())
	totalLanternsSeen = l // v - 1 // v + L // v - r // v
	if l % v == 0 and v != 1:
		totalLanternsSeen -= 1
	print(totalLanternsSeen)


from math import *
t = int(input())
for z in range(t):
	(l, v, x, y) = map(int, input().split())
	ans = l // v
	if x % v == 0:
		ans -= y // v - x // v + 1
	else:
		ans -= y // v - x // v
	print(ans)


for i in range(int(input())):
	(a, v, l, r) = map(int, input().split())
	ans = a // v - (r // v - (l - 1) // v)
	print(ans)


t = int(input())
for _ in range(t):
	(d, v, l, r) = map(int, input().split())
	x = d // v
	y = r // v - (l - 1) // v
	print(x - y)


t = int(input())
while t > 0:
	t = t - 1
	a = list(map(int, input().split()))
	L = a[0]
	v = a[1]
	l = a[2]
	r = a[3]
	ans = int(0)
	ans = int(L / v) - (int(r / v) - int((l - 1) / v))
	print(ans)


for u in range(int(input())):
	(l, v, x, y) = map(int, input().split())
	s = l // v
	w = (x - 1) // v
	ww = y // v
	c = ww - w
	print(s - c)


for _ in range(int(input())):
	(L, V, l, r) = list(map(int, input().split()))
	print(L // V - (r // V - (l - 1) // V))


from sys import stdin, stdout
from collections import Counter

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

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

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
for i in range(ip()):
	(s, e, ts, te) = ei()
	print(s // e - te // e + (ts - 1) // e)


t = int(input())
for _ in range(t):
	(l, u, x, y) = [int(x) for x in input().split()]
	b1 = (x - 1) // u
	b2 = y // u
	b = b2 - b1
	c = l // u
	print(c - b)


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	a = L // v
	x = r // v
	l = l - 1
	y = l // v
	a = a - (x - y)
	print(a)


value = int(input())
array = []
for i in range(value):
	(a, b, c, d) = input().split()
	array.append([int(a), int(b), int(c), int(d)])

def check():
	for (a, b, c, d) in array:
		if c % b != 0 and d % b != 0:
			print(int(a / b) - int(d / b) + int(c / b))
		else:
			print(int(a / b) - int((d - c) / b + 1))
check()


for t in range(int(input())):
	(l, v, b, e) = map(int, input().split(' '))
	if b % v == 0:
		q = (e - b) // v
		s = q + 1
		print(l // v - s)
	elif b <= (b // v + 1) * v <= e:
		q = (e - (b // v + 1) * v) // v
		s = q + 1
		print(l // v - s)
	else:
		print(l // v)


t = int(input())
alfa = []
for i in range(t):
	(ll, v, l, r) = map(int, input().split())
	ans = ll // v
	ans -= r // v - (l - 1) // v
	alfa.append(str(ans))
print('\n'.join(alfa))


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
inf = pow(10, 20)

def solve(case):
	(L, v, l, r) = sep()
	print(L // v - (r // v - (l - 1) // v))
testcase(int(inp()))


t = int(input())
for x in range(t):
	(l, v, a, b) = map(int, input().split())
	res = l // v
	if a % v:
		a = a + (v - a % v)
	b = b - b % v
	q = (b - a) // v + 1
	print(res - q)


number = int(input())
for i in range(number):
	line = input()
	(L, v, l, r) = list(map(int, line.split()))
	print(int(L / v) - int(r / v) + int((l - 1) / v))


def nex(l, r, v):
	if v == 1:
		return r - l + 1
	if l % v != 0:
		l += v - l % v
	if l > r:
		return 0
	elif l == r:
		return 1
	else:
		return (r - l) // v + 1
n = int(input())
for j in range(n):
	(ln, v, l, r) = map(int, input().split())
	print(ln // v - nex(l, r, v))


from sys import stdin, stdout
import cProfile, math
from collections import Counter
printHeap = str()
test = False
memory_constrained = False

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def test_print(output):
	if test:
		stdout.write(str(output) + '\n')

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

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

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def main():
	for _ in range(get_int()):
		(lent, v, l, r) = get_tuple()
		total = lent // v
		sub = r // v - l // v
		if l % v == 0:
			sub += 1
		print(total - sub)
cProfile.run('main()') if test else main()


t = int(input())
for i in range(0, t):
	(f, v, l, r) = map(int, input().split(' '))
	print(f // v - (-((l - 1) // v) + r // v))


n = int(input())
count = 0
for _ in range(n):
	(dest, interval, sLeft, sRight) = list(map(int, input().split(' ')))
	nrLant = dest // interval
	lower = sLeft // interval
	upper = sRight // interval
	if lower * interval >= sLeft:
		lower -= 1
	print(nrLant + lower - upper)


x = int(input())
for i in range(x):
	(a, b, c, d) = map(int, input().split())
	t = a // b
	r = c // b
	if c % b == 0:
		r = r - 1
	r1 = d // b
	print(t - r1 + r)


t = int(input())
for tt in range(0, t):
	s = list(map(int, input().split(' ')))
	L = s[0]
	v = s[1]
	l = s[2]
	r = s[3]
	ans = L // v
	ans -= r // v
	ans += (l - 1) // v
	print(ans)


tc = int(input())
while tc > 0:
	(L, v, l, r) = map(int, input().split())
	total = L // v
	print(total - r // v + (l - 1) // v)
	tc -= 1


t = int(input())
for times in range(t):
	(L, v, l, r) = map(int, input().split())
	nl = L // v
	nlnv = r // v - (l - 1) // v
	print(nl - nlnv)


t = int(input())
for i in range(t):
	(L, u, l, r) = list(map(int, input().split()))
	a = L // u - (r // u - (l - 1) // u + 1)
	print(a + 1)


for _ in range(int(input())):
	(L, u, l, r) = map(int, input().split())
	print(L // u - r // u + (l - 1) // u)


import sys

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

def main():
	T = int(input())
	for i in range(T):
		(L, v, l, r) = readline()
		vi = L // v
		l1 = l // v
		l2 = r // v
		train = l2 - l1
		if l % v == 0:
			train += 1
		print(vi - train)
main()


t = int(input())
for i in range(t):
	(n, v, L, R) = map(int, input().split())
	ans = n // v - R // v + (L - 1) // v
	print(ans)


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
import math
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
t = int(input())
while t:
	t -= 1
	(n, v, l, r) = inp()
	r = r // v
	n = n // v
	if l % v == 0:
		l = l // v
	else:
		l = l // v + 1
	print(n - (r - l + 1))


t = int(input())
for i in range(t):
	(s, v, l, r) = map(int, input().split())
	temp1 = l // v + (-1 if l % v == 0 else 0)
	temp2 = r // v
	answer = s // v - (temp2 - temp1)
	print(answer)


for _ in range(int(input())):
	(dest, v, l, r) = map(int, input().split())
	missing = r // v - (l - 1) // v
	print(dest // v - missing)


t = int(input())
for i in range(t):
	b = list(map(int, input().split()))
	k = max(1, b[2])
	p = min(b[3], b[0])
	r = int(p // b[1])
	s = int(k // b[1])
	if k % b[1] == 0:
		r += 1
	print(int(b[0] // b[1]) - (r - s))


x = int(input())
for _ in range(x):
	a = [int(i) for i in input().split()]
	l = a[0] // a[1]
	b = a[3] // a[1] - (a[2] - 1) // a[1]
	print(l - b)


def main():
	t = int(input())
	for _ in range(t):
		(L, v, l, r) = list(map(int, input().split()))
		numbefore = (l - 1) // v
		numduring = r // v
		numafter = L // v
		print(numafter - (numduring - numbefore))

def __starting_point():
	main()
__starting_point()


f = lambda L, v, l, r: print(L // v - (r - (l - 1) // v * v) // v)
for i in range(int(input())):
	f(*map(int, input().split()))


n = int(input())
a = [0 for _ in range(n)]
for i in range(n):
	(L, v, l, r) = map(int, input().split())
	a[i] = L // v - r // v + (l - 1) // v
print(*a, sep='\n')


for _ in range(int(input())):
	(n, v, l, r) = map(int, input().split())
	print(n // v - r // v + (l - 1) // v)


t = int(input())
for o in range(t):
	(n, v, l, r) = list(map(int, input().split()))
	ans = n // v - r // v + (l - 1) // v
	print(ans)


n = int(input())
for i in range(n):
	(a, b, l, r) = [int(i) for i in input().split(' ')]
	ans = (l - 1) // b + a // b - r // b
	print(ans)


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split(' '))
	N_lantern = int(L / v)
	N_lantern_before_left = int((l - 1) / v)
	N_lantern_before_right = int(r / v)
	N_hidden_lanterns = N_lantern_before_right - N_lantern_before_left
	print(N_lantern - N_hidden_lanterns)


t = int(input())
a = list()
while t > 0:
	(L, v, l, r) = input().split()
	L = int(L)
	v = int(v)
	l = int(l)
	r = int(r)
	t -= 1
	if l % v != 0:
		l = (l // v + 1) * v
	if r % v != 0:
		r -= r % v
	a.append(L // v - ((r - l) // v + 1))
for ans in a:
	print(ans)


for i in range(int(input())):
	(l, v, u, r) = map(int, input().split())
	print(l // v - (r // v - (u - 1) // v))


import sys

class Input(object):

	def __init__(self):
		self.fh = sys.stdin

	def next_line(self):
		return sys.stdin.readline()

	def next_line_ints(self):
		line = self.next_line()
		return [int(x) for x in line.split()]

def get_points(L, v):
	return L // v

def main():
	input = Input()
	t = input.next_line_ints()[0]
	for _ in range(t):
		(L, v, l, r) = input.next_line_ints()
		res = get_points(L, v) - (get_points(r, v) - get_points(l - 1, v))
		print('{}'.format(res))
main()


n = int(input())
while n:
	l = list(map(int, input().split()))
	r = l[0] // l[1]
	t = l[3] // l[1] - (l[2] - 1) // l[1]
	print(r - t)
	n -= 1


for _ in range(int(input())):
	(l, v, s, e) = map(int, input().split())
	ans = l // v - (e // v - (s - 1) // v)
	print(ans)


from math import ceil, floor
t = int(input())
for _ in range(t):
	(L, v, l, r) = map(int, input().split())
	n = L // v
	n1 = floor(r / v) - ceil(l / v) + 1
	print(n - n1)


n = int(input())
for i in range(n):
	sum = 0
	(L, v, l, r) = map(int, input().split(' '))
	ans = L // v - (r // v - (l - 1) // v)
	print(ans)


from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	for line in stdin.readlines():
		(L, v, l, r) = [int(c) for c in line.split()]
		res = 0
		if l <= L:
			r = min(L, r)
			res = int(L / v) - (int(r / v) - int((l - 1) / v))
		stdout.write(str(res) + '\n')
main()


for _ in range(int(input())):
	(L, v, l, r) = list(map(int, input().split()))
	times = L // v
	if l % v == 0:
		f = l
	else:
		x = l % v
		f = l + (v - x)
	y = (r - f) // v
	y += 1
	print(times - y)


T = int(input())
for i in range(T):
	(L, v, l, r) = [int(i) for i in input().split()]
	print(L // v - (r // v - (l - 1) // v))


from math import ceil
t = int(input())
for i in range(t):
	ans = 0
	(L, v, l, r) = [int(x) for x in input().split()]
	fo = L // v
	ne1 = r // v
	ne2 = l // v
	if r % v == 0 and l % v == 0:
		ne1 += 1
	elif l % v == 0:
		ne2 -= 1
	print(fo - ne1 + ne2)


T = int(input())
while T:
	(L, v, l, r) = map(int, input().split())
	ans = L // v
	ans -= r // v
	ans += (l - 1) // v
	print(ans)
	T -= 1


n = int(input())
for i in range(n):
	(L, v, l, r) = input().split()
	L = int(L)
	v = int(v)
	l = int(l)
	r = int(r)
	sum = L // v - (r // v - (l - 1) // v)
	print(sum)


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	cnt = a // b + c // b - d // b
	if c % b == 0:
		cnt -= 1
	print(cnt)


n = int(input())
for i in range(0, n):
	p = input().rstrip().split(' ')
	A = int(p[0]) // int(p[1])
	B = int(p[2]) // int(p[1])
	C = int(p[3]) // int(p[1])
	D = C - B
	if int(p[2]) % int(p[1]) == 0 or (int(p[2]) % int(p[1]) == 0 and int(p[3]) % int(p[1]) == 0):
		D += 1
	print(A - D)


n = int(input())
for i in range(n):
	(a, v, l, r) = map(int, input().split())
	n = a // v
	if l % v == 0:
		n -= r // v - l // v + 1
	else:
		n -= r // v - l // v
	print(n)


n = int(input())
for _ in range(n):
	(a, b, c, d) = map(int, input().split())
	z = a // b - (d // b - c // b)
	if c % b == 0:
		z -= 1
	print(z)


cases = int(input())
for case in range(cases):
	(L, v, l, r) = [int(i) for i in input().split()]
	see_l = (l - 1) // v
	see_L = L // v
	see_r = r // v
	print(see_L + see_l - see_r)


t = int(input())
while t > 0:
	(l, v, p1, p2) = map(int, input().strip().split())
	c = 0
	if p2 == l and p1 == 1:
		print(0)
	else:
		k = l // v
		if p1 % v == 0:
			print(k - (p2 // v - p1 // v + 1))
		else:
			print(k - (p2 // v - p1 // v))
	t -= 1


a = int(input())
for i in range(a):
	(L, v, l, r) = map(int, input().split())
	temp = L // v - (r - (l - 1) // v * v) // v
	print(temp)


t = int(input())
result = []
for _ in range(t):
	c = input().split()
	(L, v, l, r) = (int(c[0]), int(c[1]), int(c[2]), int(c[3]))

	def get_count(start, end):
		if end < start:
			return 0
		elif start == end:
			return 1 if start % v == 0 else 0
		else:
			f = (start - 1) // v
			s = end // v
			return s - f
	count_lights = 0
	if l <= L <= r:
		print(get_count(1, l - 1))
	elif L < l:
		print(get_count(1, L))
	else:
		left = get_count(1, l - 1)
		print(get_count(1, l - 1) + get_count(r + 1, L))


t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	ans = a // b
	if c % b == 0:
		ans += c // b - 1
	else:
		ans += c // b
	ans -= d // b
	print(ans)


t = int(input())
for _ in range(t):
	(L, v, l, r) = [int(x) for x in input().split()]
	total = L // v
	fb = l + (v - l % v) % v
	nots = 0
	if fb <= r:
		nots = (r - fb) // v + 1
	print(total - nots)


t = int(input())
cur = []
for i in range(t):
	(l, v, s, e) = input().split()
	l = int(l)
	v = int(v)
	s = int(s) - 1
	e = int(e)
	temp = l // v - (e // v - s // v)
	cur.append(temp)
for i in range(t):
	print(cur[i])


t = int(input())
while t:
	(L, a, l, r) = map(int, input().split())
	start = l // a * a
	if start < l:
		start += a
	end = r // a * a
	n = (end - start) // a + 1
	print(L // a - n)
	t -= 1


def fonary(lst):
	a = list()
	for elem in lst:
		a.append(elem[0] // elem[1] - elem[3] // elem[1] + (elem[2] - 1) // elem[1])
	return a
n = int(input())
c = list()
for i in range(n):
	b = [int(i) for i in input().split()]
	c.append(b)
print(*fonary(c), sep='\n')


from sys import stdin

def main():
	T = int(input())
	L = [tuple(map(int, input().split())) for _ in [0] * T]
	for (dest, v, l, r) in L:
		l_ = (l - 1) // v
		r_ = dest // v - r // v
		print(l_ + r_)
input = lambda : stdin.readline()
main()


I = lambda : list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(L, v, l, r) = I()
	if v == 1:
		print(l - 1 + L - r)
		continue
	r += v - r % v
	L -= L % v
	ln = L - r + 1
	print((l - 1) // v + (ln + v - 1) // v)


t = int(input())
while t > 0:
	(L, v, l, r) = map(int, input().split())
	ans = L // v
	a = r // v
	l = l - 1
	b = l // v
	print(ans - (a - b))
	t -= 1


from math import floor, ceil
for _ in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	lanterns_before_end = int(floor(r / v))
	lanterns_before_start = int(ceil(l / v)) - 1
	total = int(floor(L / v))
	print(total - lanterns_before_end + lanterns_before_start)


def sol():
	rd = lambda : list(map(int, input().split()))
	n = int(input())
	for i in range(n):
		(L, v, l, r) = rd()
		cnt = 0
		int1 = (0, l - 1)
		int2 = (r + 1, L)
		cnt += int(int1[1] / v)
		cnt += int(int2[1] / v) - int(int2[0] / v)
		if int2[0] % v == 0:
			cnt += 1
		print(cnt)

def main():
	sol()
main()


def solve(L, v, l, r):
	x = L // v - (r // v - (l - 1) // v)
	return x
t = int(input())
for case in range(t):
	ans = solve(*[int(x) for x in input().split(' ')])
	print(ans)


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main():
	t = int(input())
	for _ in range(t):
		(L, v, l, r) = map(int, input().split())
		print(L // v - (r // v - (l - 1) // v))
main()


from math import ceil
t = int(input())
for _ in range(t):
	(L, v, l, r) = [int(a) for a in input().split()]
	lanterns = L // v
	firstcovered = ceil(l / v) * v
	if firstcovered == r:
		lanterns -= 1
	elif firstcovered < r:
		lanterns -= 1
		lanterns -= (r - firstcovered) // v
	print(lanterns)


def nmul(x, r, l):
	return l // x - (r - 1) // x
k = int(input())
Lg = []
v = []
r = []
l = []
for i in range(k):
	(Lgi, vi, ri, li) = map(int, input().split())
	Lg.append(Lgi)
	v.append(vi)
	r.append(ri)
	l.append(li)
for i in range(k):
	print(nmul(v[i], 1, Lg[i]) - nmul(v[i], r[i], l[i]))


for i in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	all = L // v
	l += v - l % v if l % v else 0
	r -= r % v
	if l <= r:
		all -= (r - l + v) // v
	print(all)


n = int(input())
wok = {}
ar1 = []
for i in range(n):
	ar1 = str(input()).split(' ')
	wok[i] = ar1
	ar1 = []
out = 0
sw = []
sw1 = []
for key in wok.keys():
	L = int(wok[key][0])
	v = int(wok[key][1])
	l = int(wok[key][2])
	r = int(wok[key][3])
	ass = L // v
	atstart = (l - 1) // v
	inrang = r // v - atstart
	infin = L // v - r // v
	print(atstart + infin)


def mainA():
	T = int(input())
	for i in range(T):
		(L, v, l, r) = map(int, input().split())
		ans = L // v
		dow = l // v * v
		up = r // v * v
		if dow < l:
			dow += v
		ans -= max((up - dow) // v + 1, 0)
		print(ans)
mainA()


n = int(input())
for x in range(0, n, +1):
	(d, l, p, k) = map(int, input().split())
	wyn = int(p / l) + int((d - k + k % l) / l)
	if p % l == 0:
		wyn -= 1
	print(wyn)


k = int(input())
for i in range(k):
	(L, v, l, r) = map(int, input().split())
	print(L // v - r // v + (l - 1) // v)


def calculate(row):
	(finish, period, start, end) = row
	count = finish // period
	skip = end // period - start // period
	if start % period == 0:
		skip += 1
	return count - skip
n = int(input())
data = []
for j in range(n):
	z = [int(a) for a in input().split(' ')]
	data.append(z)
result = []
for row in data:
	res = calculate(row)
	result.append(res)
for res in result:
	print(res)


t = int(input())
for i in range(t):
	(l, v, li, ri) = map(int, input().split())
	_all = l // v
	f = ri // v
	s = li // v
	delta = f - s
	if li % v == 0:
		delta += 1
	ans = _all - delta
	print(ans)


t = int(input())
for _ in range(t):
	(d, v, l, r) = map(int, input().split())
	have = d // v
	exp = r // v - (l - 1) // v
	print(have - exp)


import math

def main():
	(L, v, l, r) = map(int, input().split())
	if l == 1:
		temp = 0
	else:
		temp = (l - 1) // v
	print(L // v - r // v + temp)

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


n = int(input())
sp = []
for i in range(n):
	sp.append(list(map(int, input().split())))
for info in sp:
	if info[3] % info[1] == 0 and info[2] % info[1] != 0:
		print(info[0] // info[1] - (info[3] // info[1] - info[2] // info[1]))
	elif info[2] % info[1] == 0 or info[3] % info[1] == 0:
		print(info[0] // info[1] - (info[3] // info[1] - info[2] // info[1] + 1))
	else:
		print(info[0] // info[1] - (info[3] // info[1] - info[2] // info[1]))


t = int(input())
for i in range(t):
	(L, v, l, r) = [int(z) for z in input().split()]
	n = L // v
	m = r // v - (l - 1) // v
	print(n - m)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	x = l[0] // l[1]
	y = l[2] // l[1]
	z = l[3] // l[1]
	a = l[2] % l[1]
	if a == 0:
		print(x - (z - y + 1))
	else:
		print(x - (z - y))


import math
t = int(input())
while t > 0:
	t -= 1
	(L, v, l, r) = map(int, input().split())
	y = L // v
	if l % v == 0:
		y -= r // v - (l // v - 1)
	else:
		y -= r // v - l // v
	print(y)


t = int(input())
for _ in range(0, t):
	(L, v, l, r) = map(int, input().split())
	if l % v != 0:
		c1 = l // v
	else:
		c1 = l // v - 1
	c2 = L // v
	x = r // v
	c2 -= x
	print(c1 + c2)


n = int(input())

def func(a, b, c, d):
	res = a // b - (d // b - (c - 1) // b)
	return res
for i in range(n):
	(L, v, r, l) = list(map(int, input().split()))
	print(func(L, v, r, l))


t = int(input())
while t:
	(le, v, l, r) = map(int, input().split())
	ct1 = (l - 1) // v
	ct2 = le // v
	ct3 = r // v
	print(ct1 + ct2 - ct3)
	t -= 1


a = int(input())
for i in range(a):
	b = list(map(int, input().split()))
	lanterns = b[0] // b[1]
	c = b[2] % b[1]
	lanterns -= (b[3] - b[2] + c) // b[1]
	if b[2] % b[1] == 0:
		lanterns -= 1
	print(lanterns)


t = int(input())
for i in range(t):
	(L, v, l, r) = [int(s) for s in input().split()]
	l -= 1
	ans = L // v - (r - l) // v
	if l // v < (l + (r - l) % v) // v:
		ans -= 1
	print(ans)


test = int(input())
while test > 0:
	test -= 1
	(l, v, a, b) = map(int, input().split())
	if a // v == a / v:
		print(l // v - 1 - (b // v - a // v))
	else:
		print(l // v - (b // v - a // v))


t = int(input())
for i in range(t):
	inputs = input().split()
	inputs = [int(x) for x in inputs]
	(destination, lantern_interval, left, right) = inputs
	num_lanterns = destination // lantern_interval
	if left % lantern_interval == 0:
		bottom = left
	else:
		bottom = (left // lantern_interval + 1) * lantern_interval
	top = right // lantern_interval * lantern_interval
	if bottom < top:
		num_lanterns -= (top - bottom) // lantern_interval + 1
	if bottom == top and top % lantern_interval == 0:
		num_lanterns -= 1
	print(num_lanterns)


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi

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

def si():
	return str(input())

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

def li():
	return list(mi())
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
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

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

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 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 gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)
	print(l)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans
t = ii()
for a0 in range(t):
	(L, v, l, r) = mi()
	a = L // v
	b = r // v - (l - 1) // v
	print(a - b)


t = int(input())
for _ in range(t):
	(L, v, l, r) = map(int, input().split())
	n1 = (L - v) // v + 1
	n2 = 0
	if v <= l or l <= v <= r:
		if l <= v <= r:
			n2 = (r - v) // v + 1
		else:
			n3 = (l - v) // v + 1
			z1 = 2 * v + (n3 - 1) * v
			if z1 - v == l:
				z1 = l
			if l <= z1 <= r:
				n2 = (r - z1) // v + 1
	print(n1 - n2)


n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
for j in l:
	print(j[0] // j[1] - (j[-1] // j[1] - (j[2] - 1) // j[1]))


t = int(input())
savePath = []
for conf in range(t):
	path = [int(item) for item in input().split()]
	savePath.append(path)
for item in savePath:
	L = item[0]
	v = item[1]
	l = item[2]
	r = item[3]
	if l == 1 and r >= L:
		print(0)
	else:
		numLantern = int(L / v)
		numLeft = int(l / v)
		numRight = int(r / v)
		if l % v == 0:
			print(numLantern - (numRight - numLeft) - 1)
		else:
			print(numLantern - (numRight - numLeft))


n = int(input())
ans = []
for i in range(1, n + 1):
	(place, light, begin, end) = input().split()
	place = int(place)
	light = int(light)
	begin = int(begin)
	end = int(end)
	count = (begin - 1) // light + place // light - end // light
	ans.append(count)
for elem in ans:
	print(elem)


t = int(input())
for i in range(0, t):
	s = input().split()
	Tot = int(s[0]) // int(s[1])
	LeftLen = (int(s[2]) - 1) // int(s[1])
	RightLen = int(s[3]) // int(s[1])
	Ans = Tot + LeftLen - RightLen
	print(Ans)


n = input()
n = int(n)
for i in range(n):
	(length, coordinates, begin, end) = map(int, input().split())
	length = int(length)
	coordinates = int(coordinates)
	begin = int(begin)
	end = int(end)
	time = int(length / coordinates) - (int(end / coordinates) - int((begin - 1) / coordinates))
	print(int(time))


n = int(input())
a = []
for p in range(n):
	(L, v, l, r) = map(int, input().split())
	kv = L // v
	kn = r // v - (l - 1) // v
	k = kv - kn
	a.append(k)
for q in a:
	print(q)


import sys
from itertools import accumulate

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

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 list4d(a, b, c, d, e):
	return [[[[e] * d for j 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 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, v, l, r) = MAP()
	total = N // v
	l = l if l % v == 0 else l + (v - l % v)
	r = r - r % v
	seg = r - l
	ans = total - (seg // v + 1)
	print(ans)


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
for _ in range(int(input())):
	(d, v, l, r) = map(int, input().split())
	block = (r - r % v) // v - math.ceil(l / v) * v // v + 1
	op = d // v
	ans = op - block
	print(ans)


t = int(input())
for i in range(t):
	(le, v, l, r) = map(int, input().split())
	print(le // v - r // v + (l - 1) // v)


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

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

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

def si():
	return input()
t = ii()
while t:
	t -= 1
	(L, v, l, r) = mi()
	x = L // v
	if l % v:
		l += v - l % v
	if l <= r:
		if x == 0:
			print('0')
		else:
			y = 1
			y += (r - l) // v
			print(x - y)
	else:
		print(x)


n = int(input())
tests = []
for _ in range(n):
	tests.append(list(map(int, input().split())))
for test in tests:
	(L, v, l, r) = test
	answer = L // v
	ll = l // v * v
	if ll == l:
		answer -= 1
	answer -= (r - ll) // v
	print(answer)


b = int(input())
for i in range(b):
	a = list(map(int, input().split()))
	print(a[0] // a[1] - a[3] // a[1] + (a[2] - 1) // a[1])


t = int(input())
ans = []
for test in range(t):
	(dest, v, l, r) = [int(x) for x in input().split()]
	noOfLantens = int(dest / v)
	noOfLantensOccr = int(r / v)
	noOfLantensOccl = int(l / v)
	noOfLantensOcc = noOfLantensOccr - noOfLantensOccl
	if l % v == 0:
		noOfLantensOcc += 1
	print(noOfLantens - noOfLantensOcc)


import math
t = int(input())
for test in range(t):
	arr = list(map(int, input().split()))
	ll = arr[0]
	v = arr[1]
	l = arr[2]
	r = arr[3]
	xx = math.floor(ll / v)
	yy = math.floor((l - 1) / v)
	zz = math.floor(r / v)
	print(xx + yy - zz)


def main():
	t = int(input(''))
	while t > 0:
		lista = input('').split()
		calcular(lista[0], lista[1], lista[2], lista[3])
		t -= 1

def calcular(a, b, c, d):
	a = int(a)
	b = int(b)
	c = int(c)
	d = int(d)
	cantLinternaTotal = a // b
	tapa = d // b - (c + b - 1) // b
	cantLinterna = cantLinternaTotal - tapa
	print(cantLinterna - 1)
main()


i = 0
n = int(input())
while i < n:
	(a, b, c, d) = map(int, input().split())
	x = d // b - c // b
	if c % b == 0:
		x += 1
	print(a // b - x)
	i += 1


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	(L, v, l, r) = mi()
	cl = l
	if cl > v and cl % v:
		cl -= cl % v
		cl += v
	elif cl < v:
		cl = v
	cr = r
	if cr > v:
		cr -= cr % v
	print(max(0, L // v - ((cr - cl) // v + 1)))


n = int(input())
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	m = a // b
	x = c // b if c % b != 0 else c / b - 1
	y = d // b
	print(str(int(m - y + x)))


read = lambda : [int(i) for i in input().split()]
t = read()[0]
for _ in range(t):
	(L, v, l, r) = read()
	l -= 1
	print(L // v - r // v + l // v)


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
INF = float('inf')

def solve():
	(n, v, l, r) = mp()
	t = n // v
	a = r // v
	b = l // v
	x = a - b
	if l % v == 0:
		x += 1
	pr(t - x)
for _ in range(inp()):
	solve()


(z, zz, dgraphs) = (input, lambda : list(map(int, z().split())), {})
from string 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

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:
			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 = int(z())
for _ in range(num):
	(a, b, c, d) = zz()
	co = a // b
	if c % b == 0:
		co -= d // b - c // b + 1
	else:
		co -= d // b - c // b
	print(co)


t = int(input())
for _ in range(t):
	(d, p, l, r) = input().split()
	(d, p, l, r) = (int(d), int(p), int(l), int(r))
	total = d // p - p // p + 1
	if l % p == 0:
		inside = r // p - l // p + 1
	else:
		inside = r // p - l // p
	print(total - inside)


import sys
import math
from collections import deque
n = int(input())
for _ in range(n):
	(L, v, l, r) = map(int, input().split())
	lamps = []
	con = 0
	start = math.ceil(l / v)
	end = math.floor(r / v)
	print(L // v - (end - start + 1))


t = int(input())
for i in range(t):
	(L, z, l, r) = map(int, input().strip().split(' '))
	c = (l - 1) // z + L // z - r // z
	print(c)


for i in range(int(input())):
	arr = list(map(int, input().split()))
	a1 = arr[0] // arr[1]
	a2 = arr[3] // arr[1] - (arr[2] - 1) // arr[1]
	print(a1 - a2)


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):
	(d, v, l, r) = map(int, sys.stdin.readline().split(' '))
	total = d // v
	v1 = r // v
	v2 = l // v
	if l % v != 0:
		v2 += 1
	total -= v1 - v2 + 1
	print(total)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


for _ in range(int(input())):
	(total, v, l, r) = [int(x) for x in input().split()]
	z = r // v - l // v
	deleted = z if l % v != 0 else z + 1
	print(total // v - deleted)


n = int(input())
for x in range(n):
	tam = 0
	sam = 0
	kom = 0
	tod = 0
	tid = 0
	kam = 0
	(d, v, l, r) = list(map(int, input().split()))
	if l <= d:
		tid = l % v
		if tid != 0:
			kam = l + (v - tid)
			if kam <= d:
				kom = kam // v
			else:
				kom = 0
		else:
			kam = l
			kom = kam // v
		if r <= d:
			sam = r // v
		else:
			sam = d // v
		tod = d // v
		if sam != 0 and kom != 0:
			print(tod - (sam - kom + 1))
		else:
			print(tod)
	else:
		print(0)


n = int(input())
N = 0
otvet = ''
for x in range(n):
	N = 0
	(L, v, l, r) = map(int, input().split())
	N = L // v
	k = r // v
	q = (l - 1) // v
	N -= k - q
	otvet += str(N) + '\n'
print(otvet)


t = int(input())
for _ in range(t):
	(L, v, l, r) = map(int, input().split())
	total = L // v
	t1 = l // v
	t2 = r // v
	remain = t2 - t1
	if l % v == 0:
		remain += 1
	print(total - remain)


t = int(input())
for i in range(t):
	(L, v, l, r) = [int(i) for i in input().split()]
	count = int((l - 1) / v) - int(r / v) + int(L / v)
	print(count)


import os
import sys
from io import BytesIO, IOBase
from math import ceil

def solution(L, v, l, r):
	if v == 1:
		write(L - (r - l + 1))
		return
	total = L // v
	lx = l % v
	if lx:
		l += v - lx
	r -= r % v
	write(total - ((r - l) // v + 1))

def main():
	for _ in range(r_int()):
		(L, v, l, r) = r_array()
		solution(L, v, l, r)
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
res = []
t = int(input())
for x in range(t):
	(L, v, l, r) = map(int, input().split())
	res.append(L // v - r // v + (l - 1) // v)
for x in res:
	print(x)


t = int(input())
for o in range(t):
	(l, v, f, s) = list(map(int, input().split()))
	re = s // v - (f - 1) // v
	res = l // v - re
	print(res)


T = int(input())
for _ in range(T):
	arr = list(map(int, input().split()))
	a = arr[0] // arr[1]
	if arr[2] % arr[1] == 0:
		b = arr[2] // arr[1] - 1
	else:
		b = arr[2] // arr[1]
	c = arr[3] // arr[1]
	if a - c + b >= 0:
		print(a - c + b)
	else:
		print(0)


for _ in range(int(input())):
	(n, v, l, r) = [int(x) for x in input().split()]
	ans = n // v
	num = r // v - (l - 1) // v
	print(ans - num)


for _ in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	(num1, num2, num3) = (L // v, (l - 1) // v, r // v)
	print(num1 + num2 - num3)


t = int(input())
while t:
	(L, v, l, r) = map(int, input().split())
	init = 0
	final = 0
	total = 0
	if l % v == 0:
		init = l // v
	if l % v != 0:
		init = l // v
		init = init + 1
	final = r // v
	total = L // v
	ans = total - (final - init + 1)
	print(ans)
	t -= 1


def coun(L, v, l, r):
	count = int(L / v) - countD(l, r, v)
	return count

def countD(l, r, v):
	if l % v == 0:
		return int(r / v) - int(l / v) + 1
	return int(r / v) - int(l / v)
t = int(input())
for i in range(t):
	(L, v, l, r) = [int(x) for x in input().split()]
	print(coun(L, v, l, r))


t = int(input())
for _ in range(t):
	(a, v, l, r) = map(int, input().split())
	ans = a // v
	s = r // v
	t = (l - 1) // v
	ans -= s - t
	print(ans)


t = input()
t = int(t)
while t:
	(e, v, l, r) = input().split()
	e = int(e)
	v = int(v)
	l = int(l)
	r = int(r)
	res = e // v
	if l % v != 0:
		st = l // v + 1
	else:
		st = l // v
	en = r // v
	print(res - (en - st + 1))
	t = t - 1


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(L, v, l, r) = [int(x) for x in inp().split()]
	print(L // v - (r // v - (l - 1) // v))


from math import floor

def getLanterCount(L, v, l, r):
	Cm = v * floor(l / v)
	if Cm == l:
		S2 = floor((r - Cm) / v) + 1
	else:
		S2 = floor((r - Cm) / v)
	St = floor(L / v)
	return St - S2
lines = int(input())
for i in range(lines):
	(Length, LanterMultiple, trianStart, trainEnd) = input().split()
	print(getLanterCount(int(Length), int(LanterMultiple), int(trianStart), int(trainEnd)))


import math
t = int(input())
for i in range(t):
	(L_g, v_g, l_g, r_g) = map(int, input().split())

	def f(L, v, l, r):
		total = math.floor(L / v)
		if l % v == 0:
			covered = 1
		else:
			covered = 0
		l = l - l % v
		r = r + v - r % v
		covered = covered + r / v - l / v - 1
		ans = total - covered
		return int(ans)
	answer = f(L_g, v_g, l_g, r_g)
	print(answer)


t = int(input())
for _ in range(t):
	(li, v, l, r) = list(map(int, input().split()))
	print(li // v + (l - 1) // v - r // v)


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
import heapq
I = sys.stdin.readline
alpha = 'abcdefghijklmnopqrstuvwxyz'
mod = 10 ** 9 + 7

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 isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	ans = ''
	for _ in range(ii()):
		(L, v, l, r) = mi()
		ttl = L // v
		c = 0
		a = r // v
		b = l // v
		c = a - b
		if l % v == 0:
			c += 1
		ans += str(ttl - c) + '\n'
	print(ans)
main()


import math
t = int(input())
for i in range(t):
	(L, u, l, r) = map(int, input().split())
	sum_m = L // u
	sum_o = math.floor(r / u) - math.ceil(l / u) + 1
	print(sum_m - sum_o)


from sys import *
input = stdin.readline
t = int(input())
for _ in range(t):
	(L, v, l, r) = map(int, input().split())
	print(L // v + (l - 1) // v - r // v)


t = int(input())
for i in range(t):
	(L, v, l, r) = input().split()
	(L, v, l, r) = (int(L), int(v), int(l), int(r))
	n = L // v
	if l % v == 0:
		l = l // v - 1
	else:
		l = l // v
	r = r // v
	c = l + n - r
	print(c)


for i in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	ans = 0
	T = L // v
	a1 = r // v
	a2 = (l - 1) // v
	ans = T - a1 + a2
	print(ans)


def cal(lo, v):
	return lo // v
q = int(input())
for _ in range(0, q):
	(L, v, l, r) = map(int, input().split())
	print(cal(L, v) - (cal(r, v) - cal(l - 1, v)))


t = int(input())
import math as m
for _ in range(t):
	(L, v, l, r) = map(int, input().split())
	first = m.ceil(l / v)
	last = m.floor(r / v)
	if first == last:
		print(L // v - 1)
		continue
	deduct = last - first + 1
	print(L // v - deduct)


t = int(input())
for i in range(0, t):
	(L, v, l, r) = [int(x) for x in input().split()]
	ans = 0
	if l % v == 0:
		ans = ans + 1
	ans = L // v - r // v + l // v - ans
	print(ans)


T = 0
L = 0
v = 0
l = 0
r = 0

def getAns(x):
	return x // v
T = int(input())
while T > 0:
	T = T - 1
	(L, v, l, r) = map(int, input().strip().split())
	print(getAns(L) - getAns(r) + getAns(l - 1))


def main():
	cases = int(input())
	for _ in range(cases):
		values = [int(ele) for ele in input().split(' ')]
		length = values[0]
		steps = values[1]
		ini_train = values[2]
		end_train = values[3]
		lamps = length // steps
		lamps_train = end_train // steps - (ini_train - 1) // steps
		print('%d' % (lamps - lamps_train))
main()


for _ in range(int(input())):
	(dest, v, l, r) = map(int, input().split())
	tot = dest // v
	upto_l = (l - 1) // v
	upto_r = r // v
	print(tot - (upto_r - upto_l))


import math
n = int(input())
ans = []
for _ in range(n):
	Lvlr = input().split()
	L = int(Lvlr[0])
	v = int(Lvlr[1])
	l = int(Lvlr[2])
	r = int(Lvlr[3])
	allLanterns = math.floor(L / v)
	no_see_lanterns = math.floor(r / v) - math.ceil(l / v) + 1
	ans.append(int(allLanterns - no_see_lanterns))
for i in range(n):
	print(ans[i])


n = int(input())
A = []
cont = 0
for i in range(n):
	a = list(map(int, input().split()))
	A += a
for i in range(0, n):
	cont = 0
	cont += A[4 * i] // A[4 * i + 1]
	cont -= A[4 * i + 3] // A[4 * i + 1] - (A[4 * i + 2] - 1) // A[4 * i + 1]
	print(cont)


for _ in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	res = L // v
	res -= r // v
	if l % v == 0:
		res += l // v - 1
	else:
		res += l // v
	print(res)


a = int(input())
for i in range(a):
	temp = input().split()
	temp = [int(i) for i in temp]
	x = temp[2] // temp[1]
	if temp[2] % temp[1] == 0:
		x -= 1
	y = temp[3] // temp[1]
	z = temp[0] // temp[1]
	print(z + x - y)


N = int(input())
for i in range(N):
	s = input()
	(L, v, l, r) = s.split(' ')
	L = int(L)
	v = int(v)
	l = int(l)
	r = int(r)
	cout = int(L / v)
	cout -= int(r / v)
	cout += int((l - 1) / v)
	print(cout)


from math import ceil
for _ in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	c = ceil(l / v) - 1
	c += L // v - ceil(r // v)
	print(c)


n = int(input())
for i in range(n):
	(L, v, l, r) = [int(i) for i in input().split()]
	x = L // v
	x2 = r // v
	x3 = (l - 1) // v
	print(x - (x2 - x3))


n = int(input())
for i in range(n):
	(le, v, l, r) = map(int, input().split())
	x = le // v + (l - 1) // v - r // v
	print(x)


t = int(input())
for i in range(t):
	(d, v, l, r) = list(map(int, input().split()))
	ans = d // v
	ans -= r // v - (l - 1) // v
	print(ans)


n = int(input())
for i in range(n):
	(end, v, l, r) = [int(x) for x in input().split()]
	l -= 1
	tot = end // v
	red = r // v - l // v
	print(tot - red)


for i in range(int(input())):
	(l, v, x, y) = map(int, input().split())
	s = l // v
	r = y // v - x // v
	if x % v == 0 and y % v == 0 or x % v == 0:
		r += 1
	print(s - r)


def solve():
	(L, v, l, r) = map(int, input().split())
	n = L // v
	n -= r // v
	n += (l - 1) // v
	return n

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


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(L, v, l, r) = I()
	ans = (l - 1) // v + L // v - r // v
	print(ans)


for _ in range(int(input())):
	(d, v, l, r) = map(int, input().split())
	res = d // v - (r // v - (l - 1) / v)
	print(int(res))


t = int(input())
while t > 0:
	(l, v, l1, r1) = [int(x) for x in input().split(' ')]
	lamp = l // v
	lamp -= r1 // v - (l1 - 1) // v
	print(lamp)
	t -= 1


n = int(input())
for i in range(n):
	(L, u, l, r) = map(int, input().split())
	fon = (l - 1) // u + (r % u + (L - r)) // u
	if fon >= 0:
		print(int(fon))
	else:
		print(0)


t = int(input())
for _ in range(t):
	(L, v, l, r) = map(int, input().split())
	(s1, e1) = (1, l - 1)
	(s2, e2) = (r + 1, L)
	s1 = (s1 + v - 1) // v * v
	e1 = e1 // v * v
	s2 = (s2 + v - 1) // v * v
	e2 = e2 // v * v
	c1 = max(0, (e1 - s1) // v + 1)
	c2 = max(0, (e2 - s2) // v + 1)
	print(c1 + c2)


t = int(input())
ss = 0
for i in range(t):
	(a, b, c, d) = list(map(int, input().split()))
	if c % b != 0:
		c = b * (c // b + 1)
	d = b * (d // b)
	print(a // b - (d - c) // b - 1)


import sys
t = int(input())
Q = [list(map(int, sys.stdin.readline().split())) for i in range(t)]
for i in range(t):
	ANS = Q[i][0] // Q[i][1] - Q[i][3] // Q[i][1] + (Q[i][2] - 1) // Q[i][1]
	sys.stdout.write(str(ANS) + '\n')


for i in range(int(input())):
	(l, v, li, ri) = [int(num) for num in input().split()]
	c = v
	if l % v != 0:
		c1 = l - l % v
	else:
		c1 = l
	if li % v != 0:
		c2 = li + abs(v - li % v)
	else:
		c2 = li
	if ri % v != 0:
		c3 = ri - ri % v
	else:
		c3 = ri
	tot = (c1 - c) // v - (c3 - c2) // v
	if tot > 0:
		print(tot)
	else:
		print(0)


n = int(input())
for i in range(n):
	(m, v, l, r) = [int(s) for s in input().split()]
	print(m // v - r // v + (l - 1) // v)


t = int(input())
for i in range(t):
	temp = input().split()
	(L, v, l, r) = (int(temp[0]), int(temp[1]), int(temp[2]), int(temp[3]))
	ans = L // v - (r // v - (l - 1) // v)
	print(ans, end='\n')


t = int(input())
for i in range(t):
	(l, v, l2, r) = list(map(int, input().split()))
	l2 -= 1
	num = l2 // v
	num2 = r // v
	print(l // v + num - num2)


t_ = list(map(int, input().split(sep=' ')))
t = t_[0]
for i in range(t):
	(L, v, l, r) = list(map(int, input().split(sep=' ')))
	num = L // v
	not_seen = r // v - l // v
	if l % v == 0:
		not_seen += 1
	print(str(num - not_seen))


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	if l % v == 0:
		f = l // v - 1
	else:
		f = l // v
	s = r // v
	print(L // v - (s - f))


k = int(input())
for j in range(k):
	(l, v, n, m) = map(int, input().split())
	q = l // v
	w = n // v
	if n % v == 0:
		w -= 1
	r = (m // v + 1) * v
	if r > l:
		t = 0
	else:
		t = (l - r) // v + 1
	print(w + t)


tc = int(input())
for ntc in range(tc):
	(N, D, L, R) = map(int, input().split())
	hasil = int(N / D)
	miner = int(R / D) - int((L - 1) / D)
	print(hasil - miner)


import math

def f(L, v, l, r):
	return math.floor(L / v) + math.ceil(l / v) - math.floor(r / v) - 1
t = int(input())
for i in range(t):
	(L, v, l, r) = [int(j) for j in input().split()]
	print(f(L, v, l, r))


e = int(input())
for i in range(e):
	f = input().split()
	if int(f[2]) % int(f[1]) == 0:
		c = int(f[2]) // int(f[1]) - 1
	else:
		c = int(f[2]) // int(f[1])
	c += int(f[0]) // int(f[1]) - int(f[3]) // int(f[1])
	print(c)


n = int(input())
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	print(a // b + (c - 1) // b - d // b)


R = lambda : list(map(int, input().split()))

def f(n, v):
	return int((n - v) / v + 1)
n = input()
for i in range(int(n)):
	(L, v, l, r) = R()
	print(f(L, v) - f(r, v) + f(l - 1, v))


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().rstrip().split(' '))
	res = int(L / v) - int(r / v) + int((l - 1) / v)
	print(res)


TN = int(input())

def solution():
	(L, v, l, r) = map(int, input().split())
	k = L // v
	a = (l - 1) // v
	b = r // v
	print(k - b + a)
while TN != 0:
	solution()
	TN -= 1


t = int(input())
for i in range(t):
	(l, v, s, r) = map(int, input().split())
	lan = int(l / v)
	neg = int(r / v) - int((s - 1) / v)
	lan -= neg
	print(lan)


t = int(input())
for x in range(t):
	(L, V, l, r) = map(int, input().split())
	print(L // V - (r // V - (l - 1) // V))


n = int(input())
z = []
for i in range(n):
	a = list(map(int, input().split()))
	e = a[0] // a[1]
	e -= a[3] // a[1] - (a[2] - 1) // a[1]
	z += [e]
for i in z:
	print(i)


import sys
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()):
	(L, v, l, r) = inpl()
	print(L // v - (r // v - (l - 1) // v))


n = int(input())
for i in range(n):
	(l, v, l1, r1) = map(int, input().split())
	lalten = int(l / v)
	m1 = int(l1 / v)
	m2 = int(r1 / v)
	if l1 % v == 0:
		m1 = m1 - 1
	print(lalten - m2 + m1)


t = int(input())
while True:
	try:
		(L, v, l, r) = map(int, input().split())
	except:
		break
	if l % v:
		a = l // v
	else:
		a = l // v - 1
	r -= r % v
	L -= L % v
	b = (L - r) // v
	print(a + b)


from sys import stdin, stdout

def find_total(L, v):
	return L // v

def find_range(v, l, r):
	first = l // v
	second = r // v
	result = second - first
	if l % v == 0:
		result += 1
	return result
t = int(stdin.readline())
while t > 0:
	(L, v, l, r) = list(map(int, stdin.readline().split()))
	a = find_total(L, v)
	b = find_range(v, l, r)
	r = a - b
	s = '%d\n' % r
	stdout.write(s)
	t -= 1


def solve(L, v, l, r):
	all = L // v
	left = l // v
	if l % v > 0:
		left += 1
	right = r // v
	hide = right - left + 1
	return all - hide
ans = []
n = int(input())
for i in range(n):
	(L, v, l, r) = map(int, input().split(' '))
	ans.append(solve(L, v, l, r))
for a in ans:
	print(a)


for i in range(int(input())):
	(L, v, l, r) = list(map(int, input().split()))
	vl = L // v - (r // v - (l - 1) // v)
	print(vl)


def run(Li, vi, li, ri):
	if Li < vi:
		return 0
	num_lanterns = Li // vi
	num_till_liminus1 = (li - 1) // vi
	num_till_ri = ri // vi
	num_cov_lanterns = num_till_ri - num_till_liminus1
	return num_lanterns - num_cov_lanterns

def main():
	t = int(input())
	answers = []
	for i in range(t):
		(Li, vi, li, ri) = [int(c) for c in input().split()]
		answers.append(run(Li, vi, li, ri))
	for ans in answers:
		print(ans)
main()


t = int(input())
for i in range(t):
	(L, v, l, r) = [int(x) for x in input().split()]
	possible = L // v
	onTrain = r // v - (l - 1) // v
	print(possible - onTrain)


t = int(input())
for tt in range(0, t):
	(length, v, r, l) = map(int, input().split())
	tl = length // v
	if r % v != 0:
		a = (r // v + 1) * v
	else:
		a = r
	n = (l - a) // v + 1
	print(tl - n)


n = int(input())
l = []
for i in range(n):
	(a, s, d, f) = input().split()
	a = int(a)
	s = int(s)
	d = int(d)
	f = int(f)
	c = int(d / s)
	if d % s == 0:
		c = c - 1
	c = c + (int(a / s) - int(f / s))
	l.append(c)
for i in l:
	print(i)


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	a = L // v
	p = r // v
	l = l - 1
	q = l // v
	a = a - (p - q)
	print(a)


(z, zz) = (input, lambda : list(map(int, z().split())))
mod = 10 ** 9 + 7
from string 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

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:
			return 0
	return 1
n = int(z())
for _ in range(n):
	(a, b, c, d) = zz()
	n = a // b
	n1 = (c - 1) // b
	n2 = d // b
	t = n - (n2 - n1)
	print(t)


def f(ll):
	(n, v, l, r) = ll
	lc = (l - 1) // v
	rc = r // v
	tc = n // v
	return lc + tc - rc
q = int(input())
for _ in range(q):
	l = list(map(int, input().split()))
	print(f(l))


t = int(input())
for y in range(t):
	s = input()
	parts = s.split()
	L = int(parts[0])
	v = int(parts[1])
	l = int(parts[2])
	r = int(parts[3])
	a = L // v
	b = r // v
	c = (l - 1) // v
	print(a - (b - c))


for i in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	a = r // v - l // v
	if not l % v and l != 0:
		a += 1
	print(L // v - a)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(l, v, ll, rr) = map(int, input().split())
	print(l // v - rr // v + (ll - 1) // v)


import math
n = int(input())
for i in range(n):
	[L, v, l, r] = map(int, input().split())
	total = L // v
	first_cover_point = math.ceil(l / v) * v
	last_cover_point = r // v * v
	covered = (last_cover_point - first_cover_point) / v + 1
	print(total - int(covered))


import math
for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	print(a // b - math.floor(d / b) + math.ceil(c / b) - 1)


def ceil(n, m):
	if n % m == 0:
		return n // m
	else:
		return n // m + 1
t = int(input())
for i in range(t):
	(s, v, l, r) = map(int, input().split())
	ans = s // v
	left = ceil(l, v)
	right = r // v
	print(ans - (right - left + 1))


def lantern_view(S):
	count1 = S[0] // S[1]
	count2 = (S[2] - 1) // S[1]
	count3 = S[3] // S[1]
	return count1 + count2 - count3
t = int(input())
for i in range(t):
	A = list(map(int, input().split()))
	print(lantern_view(A))


t = int(input())
for I in range(t):
	(L, v, l, r) = [int(i) for i in input().split()]
	tot = L // v
	if l % v == 0:
		small = l // v
	else:
		small = l // v + 1
	if r % v == 0:
		large = r // v
	else:
		large = r // v
	print(tot - (large - small + 1))


t = int(input())
for test in range(t):
	(L, v, l, r) = map(int, input().split())
	p = []
	c = 0
	k = 0
	print(L // v - r // v + (l - 1) // v)


import sys
t = int(input())
for _ in range(t):
	(L, v, l, r) = map(int, input().split())
	n1 = (l - 1) // v
	n2 = r // v
	print(L // v - (n2 - n1))


T = int(input())
for i in range(T):
	(n, v, l, r) = map(int, input().strip().split())
	num1 = int((l - 1) / v)
	num2 = int(n / v) - int(r / v)
	print(num1 + num2)


def sint():
	return int(input())

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

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

def sstr():
	s = input()
	return list(s[:len(s)])

def main():
	(L, v, l, r) = sints()
	total = L // v
	l -= 1
	total -= r // v - l // v
	print(total)
t = sint()
while t:
	t -= 1
	main()


import math

def go():
	n = int(input())
	for i in range(n):
		(L, v, l, r) = [int(i) for i in input().split(' ')]
		L = L // v * v
		left = (l - 1) // v
		if r % v == 0:
			right = (L - r) // v
		elif r == L:
			right = 0
		else:
			right = (L - r) // v + 1
		print(right + left)
go()


n = int(input())
a = []
for i in range(n):
	k = [int(i) for i in input().split()]
	a.append(k[0] // k[1] - k[3] // k[1] + (k[2] - 1) // k[1])
for i in range(n):
	print(a[i])


import math
t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().strip().split(' '))
	y = d // b
	z = c // b
	if c % b == 0:
		y += 1
	x = y - z
	print(a // b - x)


for _ in range(int(input())):
	(l, v, left, right) = [int(x) for x in input().split()]
	print(l // v - right // v + (left - 1) // v)


t = int(input())
for T in range(t):
	(L, v, l, r) = list(map(int, input().split()))
	how = L // v
	howB = r // v - (l - 1) // v
	print(how - howB)


import math
t = int(input())
ans = []
for i in range(t):
	(L, v, li, r) = map(int, input().split())
	lantern1 = len(range(v, li, v))
	if r % v == 0:
		startLoc = r + v
	else:
		startLoc = math.ceil(r / v) * v
	lantern2 = len(range(startLoc, L + 1, v))
	ans.append(lantern1 + lantern2)
print(*ans, sep='\n')


import math
for i in range(int(input())):
	(L, u, l, r) = map(int, input().split())
	q = math.ceil(l / u)
	q = q * u
	print(L // u - (r - q) // u - 1)


for x in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	lamps = L // v - r // v + l // v
	if l % v == 0:
		lamps -= 1
	print(lamps)


t = int(input())
while t:
	t -= 1
	(L, v, l, r) = [int(x) for x in input().split()]
	lantern = L // v
	count = 0
	c = 0
	if l % v == 0:
		c = l // v
	else:
		c = l // v + 1
	d = r // v
	print(lantern - (d - c + 1))


n = int(input())
for i in range(n):
	(l, v, r, d) = map(int, input().split())
	print(l // v - d // v + (r - 1) // v)


from sys import stdin
all_in = stdin.readlines()
t = int(all_in[0])
Lvlr = list(map(lambda x: tuple(map(int, x.split())), all_in[1:]))
ans = list()
for (L, v, l, r) in Lvlr:
	ans.append(L // v - r // v + (l - 1) // v)
print('\n'.join(map(str, ans)))


for y in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	cnt = 0
	cnt += a // b
	cnt -= d // b
	cnt += (c - 1) // b
	print(cnt)


t = int(input())
for i in range(t):
	(L, v, l, r) = [int(a) for a in input().split()]
	tot = L // v
	if l % v == 0:
		nl = l
	else:
		nl = l + v - l % v
	nr = r - r % v
	blocked = (nr - nl) // v + 1
	print(tot - blocked)


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split(' '))
	count = 0
	total = L // v
	count += total
	sub = r // v
	sub -= (l - 1) // v
	count -= sub
	print(count)


import sys
import math
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):
	(d, x, a, b) = invr()
	ans = d // x - (b // x - (a - 1) // x)
	print(ans)


import math
for _ in range(int(input())):
	(L, v, a, b) = map(int, input().split())
	if a % v == 0:
		num = b // v - a // v + 1
	else:
		num = b // v - a // v
	print(L // v - num)


n = int(input())
for i in range(0, n):
	(a, b, c, d) = map(int, input().split(' '))
	l = a // b
	k = (c - 1) // b
	z = d // b
	print(l - z + k)


n = int(input())
for i in range(n):
	[L, v, l, r] = map(int, input().split())
	(ll, t) = divmod(l, v)
	if t == 0:
		ll -= 1
	(rr, _) = divmod(r, v)
	(LL, _) = divmod(L, v)
	print(ll + (LL - rr))


from math import *
from string import *
from itertools import *
T = int(input())
for _ in range(T):
	ans = 0
	(destination, v, starting, ending) = map(int, input().split())
	total = destination // v
	a = ending // v
	b = (starting - 1) // v
	ans = total - a + b
	print(ans)


t = int(input())
while t:
	(s, a, b, c) = map(int, input().split())
	a1 = c // a - (b - 1) // a
	a2 = s // a
	print(a2 - a1)
	t -= 1


def solve(distance, v, l, r):
	q = (l - 1) // v
	w = r // v
	missed = w - q
	return distance // v - missed
tests = int(input())
for i in range(tests):
	(dist, v, l, r) = [int(x) for x in input().split()]
	print(solve(dist, v, l, r))


import math
x = int(input())
for _ in range(x):
	(a, b, c, d) = map(int, input().split())
	c -= 1
	e = c // b
	f = d // b
	g = f - e
	print(max(0, a // b - g))


t = int(input())
for z in range(t):
	ll = list(map(int, input().split()))
	L = ll[0]
	v = ll[1]
	l = ll[2]
	r = ll[3]
	c1 = r // v
	c2 = l // v
	lan1 = L // v - c1 + c2
	if l % v == 0:
		lan1 = lan1 - 1
	print(lan1)


import math
for _ in range(int(input())):
	(a, b, c, d) = list(map(int, input().split()))
	count = a // b
	if c % b == 0 and d % b == 0:
		count = count + c // b - d // b - 1
	elif c % b == 0 and d % b != 0:
		count = count + c // b - math.ceil(d / b)
	elif c % b != 0 and d % b == 0:
		count = count + c // b - d // b
	else:
		count = count + c // b - d // b
	print(count)


t = int(input())

def countDivisibles(A, B, M):
	if A % M == 0:
		return B // M - A // M + 1
	return B // M - A // M
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	k = countDivisibles(l, r, v)
	m = L // v
	print(int(m - k))


for i in range(int(input())):
	(n, v, l, r) = map(int, input().split())
	print(n // v - (r // v - l // v + bool(l % v == 0)))


from math import ceil
from sys import stdin
n = int(stdin.readline().strip())
for case in range(n):
	(x, v, l1, r1) = map(int, stdin.readline().strip().split())
	d = x // v
	ll1 = ceil(l1 / v) * v
	ll2 = r1 // v * v
	y = ll2 // v - ll1 // v + 1
	print(d - y)


t = int(input())
for i in range(0, t):
	(L, v, l, r) = map(int, input().split())
	tot = L // v
	t1 = r // v
	t2 = l // v
	if l % v == 0:
		t2 = t2 - 1
	rem = t1 - t2
	ans = tot - rem
	print(ans)


R = lambda : map(int, input().split())

def f(n):
	return max(0, n // v)
t = int(input())
while t:
	(L, v, l, r) = R()
	print(f(L) - f(r) + f(l - 1))
	t -= 1


def cdd(A, B, M):
	if A % M == 0:
		return B // M - A // M + 1
	return int(B // M - A // M)
t = int(input())
for _ in range(t):
	(d, p, l, h) = [int(x) for x in input().split()]
	c = d // p - cdd(l, h, p)
	print(c)


for t in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	l -= 1
	x = L // v
	f1 = r // v - l // v
	print(x - f1)


t = int(input())
while t > 0:
	t -= 1
	(L, v, l, r) = list(map(int, input().split()))
	n = L // v - r // v + (l - 1) // v
	print(n)


def lrc(lb, ub, dv):
	lb = (lb // dv + 1) * dv
	if ub % dv == 0:
		ub = (ub // dv - 1) * dv
	else:
		ub = ub // dv * dv
	if ub < lb:
		return 0
	return (ub - lb) // dv + 1
for t in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	print(lrc(0, l, v) + lrc(r, L + 1, v))


def count_col(length, v, l, r):
	res = 0
	temp1 = length // v * v
	if temp1 == r:
		res += (l - 0.5) // v
	else:
		res += (l - 0.5) // v + (temp1 - r - 0.5) // v + 1
	return int(res)
t = int(input())
for i in range(t):
	temp = input().split()
	Length = int(temp[0])
	v = int(temp[1])
	l = int(temp[2])
	r = int(temp[3])
	print(count_col(Length, v, l, r))


t = int(input())
for i in range(t):
	(l, v, x, y) = list(map(int, input().split()))
	n = l // v
	tl = y - x
	offset = x % v
	tl += offset
	blocked = tl // v
	hack = 0
	if x % v == 0:
		hack = 1
	print(n - blocked - hack)


from collections import Counter, defaultdict
BS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def to_base(s, b):
	res = ''
	while s:
		res += BS[s % b]
		s //= b
	return res[::-1] or '0'
alpha = 'abcdefghijklmnopqrstuvwxyz'
from math import floor, ceil, pi
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919]

def primef(n, plst=[]):
	if n == 1:
		return plst
	else:
		for m in primes:
			if n % m == 0:
				return primef(n // m, plst + [m])
		return primef(1, plst + [n])

def scoreBad(s):
	res = 0
	counter = 0
	while True:
		cur = int(counter)
		ok = True
		for i in range(len(s)):
			res += 1
			if s[i] == '+':
				cur += 1
			else:
				cur -= 1
			if cur < 0:
				ok = False
				break
		counter += 1
		if ok:
			break
	return res
from math import log
t = int(input())
for i in range(t):
	(le, v, l, r) = list(map(int, input().split()))
	ra = floor(r / v)
	la = floor((l - 1) / v)
	total = le // v
	print(total - ra + la)


try:
	t = int(input())
	for i in range(t):
		c = 0
		(s, v, x, y) = map(int, input().split())
		print(s // v - y // v + (x - 1) // v)
except EOFError:
	pass


n = int(input())
for i in range(n):
	(L, v, l, r) = map(int, input().split())
	allPoints = L // v
	hiddenPoints = r // v - l // v
	if l % v == 0:
		hiddenPoints += 1
	print(allPoints - hiddenPoints)


from math import ceil
t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	n = L // v
	a = int(ceil(l / v))
	b = r // v
	print(n - (b - a + 1))


import sys
input = sys.stdin.buffer.readline
T = int(input())

def f(v, x, y):
	return y // v - (x - 1) // v
for testcase in range(T):
	(L, v, l, r) = map(int, input().split())
	print(f(v, 1, L) - f(v, l, r))


t = int(input())
for _ in range(t):
	(d, v, l, r) = list(map(int, input().split()))
	hidden = r // v - (l - 1) // v
	print(d // v - hidden)


import sys
t = int(sys.stdin.readline())
for i in range(t):
	(d, v, l, r) = list(map(int, sys.stdin.readline().strip().split()))
	x = int(d / v)
	y = int(r / v) - int((l - 1) / v)
	if l == r and l % v == 0:
		y = 1
	print(x - y)


for _ in range(int(input())):
	(L, v, l, r) = list(map(int, input().split()))
	ans = L // v - (r // v - (l - 1) // v)
	print(ans)


t = int(input())
for test in range(t):
	(n, v, l, r) = map(int, input().split())
	print(n // v - r // v + (l - 1) // v)


t = int(input())
for i in range(t):
	(L, v, l, r) = map(int, input().split())
	count1 = (l - 1) // v
	count2 = L // v
	count3 = r // v
	count = count1 + count2 - count3
	print(count)


t = int(input())
n = []
V = []
L = []
R = []
Out = []
for i in range(t):
	(nn, VV, LL, RR) = map(int, input().split())
	n.append(nn)
	V.append(VV)
	L.append(LL)
	R.append(RR)
for j in range(t):
	temp1 = (L[j] - 1) // V[j]
	temp2 = (R[j] + 1) % V[j]
	if temp2 == 0:
		temp3 = (n[j] - (R[j] + 1)) // V[j] + 1
	else:
		temp3 = (n[j] - (R[j] + 1 - temp2)) // V[j]
	Out.append(temp1 + temp3)
for k in range(t):
	print(Out[k])


def search(l, h, v):
	if l % v == 0:
		return h // v - l // v + 1
	return h // v - l // v
n = int(input())
while n:
	(d, v, l, r) = input().strip().split(' ')
	d = int(d)
	v = int(v)
	l = int(l)
	r = int(r)
	count = 0
	total = search(1, d, v)
	less = search(l, r, v)
	print(total - less)
	n -= 1


tc = int(input())
for case in range(tc):
	(L, v, l, r) = map(int, input().split())
	print(L // v - (r // v - (l - 1) // v))


def coun(a, b, m):
	if a % m == 0:
		return b // m - a // m + 1
	return b // m - a // m
for t in range(int(input().strip())):
	(L, v, l, r) = map(int, input().strip().split())
	n = L // v
	cns = coun(l, r, v)
	print(n - cns)


t = int(input())
for i in range(t):
	sp = [int(i) for i in input().split()]
	(L, v, l, r) = (sp[0], sp[1], sp[2], sp[3])
	n_fon = l // v + (L // v - r // v)
	if l % v == 0:
		n_fon -= 1
	print(n_fon)


for _ in range(int(input())):
	(l, v, li, ri) = map(int, input().split())
	count = l // v
	if li % v == 0:
		count -= ri // v - li // v + 1
	else:
		count -= ri // v - li // v
	print(count)


for t in range(int(input())):
	(L, v, l, r) = list(map(int, input().split()))
	total = L // v
	q2 = r // v
	q1 = l // v if l % v != 0 else l / v - 1
	print(int(total - (q2 - q1)))


for _ in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	a = r // v - (l - 1) // v
	vo = L // v - a
	print(vo)


q = int(input())
while q > 0:
	(L, v, l, r) = map(int, input().split())
	i = (l - 1) // v
	x = L // v - r // v
	print(i + x)
	q -= 1


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

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

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
nb_test = read_int()
for _ in range(nb_test):
	(L, v, l, r) = read_ints()
	laterns = L // v
	lefts = (l - 1) // v
	rites = r // v
	can_see = laterns + lefts - rites
	print(can_see)


import math
t = int(input())
for _ in range(t):
	(l, v, m, n) = map(int, input().split())
	q = math.floor(l / v)
	w = max(math.floor(n / v) - math.floor((m - 1) / v), 0)
	print(q - w)


n = int(input())
z = []
q = []
for i in range(0, n):
	z.append(0)
	q.append(0)
	a = input()
	b = a.split(' ')
	for k in range(0, 4):
		b[k] = int(b[k])
	q[i] = b[0] // b[1] - (b[3] // b[1] - (b[2] - 1) // b[1])
for o in range(0, n):
	print(q[o])


n = int(input())
for j in range(n):
	(L, v, left, right) = list(map(int, input().split()))
	total_lamps = L // v
	closed_lamps = right // v - (left - 1) // v
	print(total_lamps - closed_lamps)


from math import ceil
t = int(input())
for _ in range(t):
	(Li, vi, li, ri) = map(int, input().split())
	start = vi * ceil(li / vi)
	print(Li // vi - max(0, ri - start) // vi - int(start <= ri))


for t in range(int(input())):
	(s, v, l, r) = map(int, input().split())
	c = 0
	q = s // v
	i = r // v
	if l % v == 0:
		j = l // v - 1
	else:
		j = l // v
	c = q - (i - j)
	print(c)


for n in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	a = L // v
	b = r // v - (l - 1) // v
	print(a - b)


import math
t = int(input())
Lvlr = []
output = ''
for i in range(t):
	Lvlr.append(list(map(int, input().split(' '))))
for i in range(t - 1):
	seeLantern = 0
	if Lvlr[i][2] % Lvlr[i][1] == 0:
		seeLantern += int(Lvlr[i][2] / Lvlr[i][1]) - 1
	else:
		seeLantern += int(Lvlr[i][2] / Lvlr[i][1])
	if Lvlr[i][3] % Lvlr[i][1] == 0:
		seeLantern += int((Lvlr[i][0] - Lvlr[i][3]) / Lvlr[i][1])
	else:
		r = math.ceil(Lvlr[i][3] / Lvlr[i][1]) * Lvlr[i][1]
		if r <= Lvlr[i][0]:
			seeLantern += int((Lvlr[i][0] - r) / Lvlr[i][1]) + 1
	output += str(seeLantern) + '\n'
seeLantern = 0
if Lvlr[-1][2] % Lvlr[-1][1] == 0:
	seeLantern += int(Lvlr[-1][2] / Lvlr[-1][1]) - 1
else:
	seeLantern += int(Lvlr[-1][2] / Lvlr[-1][1])
if Lvlr[-1][3] % Lvlr[-1][1] == 0:
	seeLantern += int((Lvlr[-1][0] - Lvlr[-1][3]) / Lvlr[-1][1])
else:
	r = math.ceil(Lvlr[-1][3] / Lvlr[-1][1]) * Lvlr[-1][1]
	if r <= Lvlr[-1][0]:
		seeLantern += int((Lvlr[-1][0] - r) / Lvlr[-1][1]) + 1
output += str(seeLantern)
print(output)


n = int(input())
for _ in range(n):
	(L, v, l, r) = list(map(int, input().split()))
	last_lamp_number_before_train = l // v if l % v != 0 else l // v - 1
	first_lamp_number_after_train = r // v
	res = L // v - (first_lamp_number_after_train - last_lamp_number_before_train)
	print(res)


n = int(input())
while n > 0:
	n -= 1
	(b, v, l, r) = (int(x) for x in input().split())
	print(int(b / v) - int(r / v) + int((l - 1) / v))


n = int(input())

def calc(L, v):
	return int(L / v)
for i in range(n):
	(L, v, start, end) = map(int, input().split())
	count = calc(L, v)
	countStart = calc(start, v)
	countEnd = calc(end, v)
	res = count - (countEnd - countStart)
	if start % v == 0:
		res -= 1
	print(res)


from sys import stdin, stdout
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))

def ceill(num, den):
	q = num // den
	if den * q < num:
		q += 1
	return q
for _ in range(nmbr()):
	(nn, d, l, r) = lst()
	tot = nn // d
	left = ceill(l, d) * d
	right = r // d * d
	rem = (right - left) // d + 1
	if left <= right:
		print(tot - rem)
	else:
		print(tot)


from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
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')
t = int(input())
while t:
	t -= 1
	(a, b, c, d) = map(int, input().split())
	print((c - 1) // b + (a // b - d // b))


num_queries = int(input())
for query in range(num_queries):
	(dest, lights, left_end, right_end) = (int(x) for x in input().split())
	ans = (left_end - 1) // lights + dest // lights - right_end // lights
	print(ans)


for _ in range(int(input())):
	(L, v, l, r) = map(int, input().split())
	total = L // v + l // v - r // v
	if l % v == 0:
		total -= 1
	print(total)


import sys

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

def rangee(a, b, v):
	if a > b:
		return 0
	return (b - a) // v + 1

def solve():
	(L, v, l, r) = map(int, minp().split())
	if L % v != 0:
		L -= L % v
	if l % v != 0:
		l += v - l % v
	if r % v != 0:
		r -= r % v
	print(rangee(v, L, v) - rangee(l, r, v))
for i in range(int(minp())):
	solve()