import java.io.*
import java.util.*
import kotlin.math.min

fun solve() {

    val n = nextInt()

    repeat(n) {
        val L = nextInt()
        val v = nextInt()
        var l = nextInt()
        var r = nextInt()

        if (v > L) {
            println(0)
        } else {
            if (r % v != 0) {
                r -= r % v
            }
            if (l % v != 0) {
                l = min(r, l - (l % v) + v)
            }

            val cnt = if (r >= v) (r - l) / v + 1 else 0
            println(L/v - cnt)
        }
    }

}

fun hasNext() : Boolean {
    while (!st.hasMoreTokens()) {
        st = StringTokenizer(input.readLine() ?: return false)
    }
    return true
}

fun next() = if (hasNext()) st.nextToken()!! else throw RuntimeException("No tokens")

fun nextInt() = next().toInt()

fun nextLong() = next().toLong()

fun nextDouble() = next().toDouble()

fun nextLine() = if (hasNext()) st.nextToken("\n")!! else throw RuntimeException("No tokens")

fun nextArray(n : Int) = IntArray(n, { nextInt() })

val ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null

var input = when(ONLINE_JUDGE) {
    true -> BufferedReader(InputStreamReader(System.`in`), 32768)
    else -> BufferedReader(FileReader("in.txt"))
}

var output = when(ONLINE_JUDGE) {
    true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))
    else -> PrintWriter(BufferedWriter(FileWriter("out.txt")))
}

var st = StringTokenizer("")

fun main(args: Array<String>) {
    val start = System.currentTimeMillis()
    solve()

    output.close()
    input.close()

    if (!ONLINE_JUDGE) {
        //System.err.println("${System.currentTimeMillis() - start} ms")
    }
}


import java.io.*
import java.util.*

fun solve() {

    val n = nextInt()

    repeat(n) {
        val L = nextInt()
        val v = nextInt()
        var l = nextInt()
        val r = nextInt()

        println(L/v  - r/v + (l-1)/v)
    }

}

fun hasNext() : Boolean {
    while (!st.hasMoreTokens()) {
        st = StringTokenizer(input.readLine() ?: return false)
    }
    return true
}

fun next() = if (hasNext()) st.nextToken()!! else throw RuntimeException("No tokens")

fun nextInt() = next().toInt()

fun nextLong() = next().toLong()

fun nextDouble() = next().toDouble()

fun nextLine() = if (hasNext()) st.nextToken("\n")!! else throw RuntimeException("No tokens")

fun nextArray(n : Int) = IntArray(n, { nextInt() })

val ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null

var input = when(ONLINE_JUDGE) {
    true -> BufferedReader(InputStreamReader(System.`in`), 32768)
    else -> BufferedReader(FileReader("in.txt"))
}

var output = when(ONLINE_JUDGE) {
    true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))
    else -> PrintWriter(BufferedWriter(FileWriter("out.txt")))
}

var st = StringTokenizer("")

fun main(args: Array<String>) {
    val start = System.currentTimeMillis()
    solve()

    output.close()
    input.close()

    if (!ONLINE_JUDGE) {
        //System.err.println("${System.currentTimeMillis() - start} ms")
    }
}


import java.io.*
import java.util.*
import kotlin.math.min

fun solve() {

    val n = nextInt()

    repeat(n) {
        val L = nextInt()
        val v = nextInt()
        var l = nextInt()
        var r = nextInt()

        if (l % v != 0) {
            l = min(r, l - (l % v) + v)
        }
        if (r % v != 0) {
            r -= r % v
        }

        println(L/v - (r-l)/v - 1)
    }

}

fun hasNext() : Boolean {
    while (!st.hasMoreTokens()) {
        st = StringTokenizer(input.readLine() ?: return false)
    }
    return true
}

fun next() = if (hasNext()) st.nextToken()!! else throw RuntimeException("No tokens")

fun nextInt() = next().toInt()

fun nextLong() = next().toLong()

fun nextDouble() = next().toDouble()

fun nextLine() = if (hasNext()) st.nextToken("\n")!! else throw RuntimeException("No tokens")

fun nextArray(n : Int) = IntArray(n, { nextInt() })

val ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null

var input = when(ONLINE_JUDGE) {
    true -> BufferedReader(InputStreamReader(System.`in`), 32768)
    else -> BufferedReader(FileReader("in.txt"))
}

var output = when(ONLINE_JUDGE) {
    true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))
    else -> PrintWriter(BufferedWriter(FileWriter("out.txt")))
}

var st = StringTokenizer("")

fun main(args: Array<String>) {
    val start = System.currentTimeMillis()
    solve()

    output.close()
    input.close()

    if (!ONLINE_JUDGE) {
        //System.err.println("${System.currentTimeMillis() - start} ms")
    }
}


import java.io.*
import java.util.*

fun main(args: Array<String>) {
    solve(System.`in`, System.out)
}

val MAX_N = (1e6 + 10).toInt()
val INF = (1e9 + 7).toInt()
val MOD = (1e9 + 7).toInt()
val INF_F = 1e-6

fun solve(input: InputStream, output: OutputStream) {
    val reader = InputReader(BufferedInputStream(input))
    val writer = PrintWriter(BufferedOutputStream(output))

    solve(reader, writer)
    writer.close()
}

fun solve(reader: InputReader, writer: PrintWriter) {
    val t = reader.nextInt()
    for (i in 0 until t) {
        val a = reader.nextInt()
        val v = reader.nextInt()
        val l = reader.nextInt()
        val r = reader.nextInt()
        writer.println(a / v - (r / v - (l - 1) / v))
    }
}

fun gcd(a: Int, b: Int): Int {
    return if (b == 0) a else gcd(b, a % b)
}

class InputReader(stream: InputStream) {
    private val reader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }
}


fun main(args: Array<String>) {

    repeat(readLine()?.toInt()!!) {

        val (totalLength, pointGauge, trainStart, trainEnd) = readLine()!!
            .split(" ")
            .map { number -> number.toInt() }

        val visitablePoints = totalLength / pointGauge
        val pointsBefore = (trainStart - 1) / pointGauge
        val pointsUntil = trainEnd / pointGauge
        val pointsMissed = pointsUntil - pointsBefore

        println(visitablePoints - pointsMissed)
    }

}


import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)

    repeat(scanner.nextInt()) {

        val totalLength = scanner.nextInt()
        val pointGauge= scanner.nextInt()
        val trainStart= scanner.nextInt()
        val trainEnd= scanner.nextInt()

        val visitablePoints = totalLength / pointGauge
        val pointsBefore = (trainStart - 1) / pointGauge
        val pointsUntil = trainEnd / pointGauge
        val pointsMissed = pointsUntil - pointsBefore

        println(visitablePoints - pointsMissed)
    }

}


fun main(args: Array<String>) {
    val iterations = readLine()?.toInt() ?: throw IllegalArgumentException("expected number of iterations")
    repeat(iterations) {
        val (totalLength, pointGauge, trainStart, trainEnd) = readLine()
            ?.split(" ")
            ?.map { number -> number.toInt() }
            ?: throw IllegalArgumentException("expected iteration info")

        val visitablePoints = totalLength / pointGauge
        val pointsBefore = trainStart / pointGauge
        val poinstUntil = trainEnd / pointGauge
        val pointsMissied = poinstUntil - pointsBefore

        val points = visitablePoints - pointsMissied
        println(points)
    }

}


fun main(args: Array<String>) {
    val iterations = readLine()?.toInt() ?: throw IllegalArgumentException("expected number of iterations")
    repeat(iterations) {
        val (totalLength, pointGauge, trainStart, trainEnd) = readLine()
            ?.split(" ")
            ?.map { number -> number.toInt() }
            ?: throw IllegalArgumentException("expected iteration info")

        val visitablePoints = totalLength / pointGauge
        val pointsBefore = (trainStart - 1) / pointGauge
        val poinstUntil = trainEnd / pointGauge
        val pointsMissied = poinstUntil - pointsBefore

        val points = visitablePoints - pointsMissied
        println(points)
    }

}


import java.io.*
import java.util.*

fun main(args: Array<String>) {

    val inputString1 = "4\n" +
            "10 2 3 7\n" +
            "100 51 51 51\n" +
            "1234 1 100 199\n" +
            "1000000000 1 1 1000000000\n"

    val stream = ByteArrayInputStream(inputString1.toByteArray())

    val input = CustomReader(System.`in`)
    //val input = CustomReader(stream)
    val output = PrintWriter(System.out)

    val solver = TaskA()
    solver.solve(1, input, output)
    output.close()
}

internal class TaskA {

    fun solve(testNumber: Int, input: CustomReader, output: PrintWriter) {

        val lines = input.nextInt()

        (0 until lines).forEach { _ ->

            val length = input.nextInt()
            val lampPos = input.nextInt()
            val trainStartPos = input.nextInt()
            val trainEndPos = input.nextInt()

            val lampCount = length / lampPos
            var invisibleLamps = (trainEndPos - trainStartPos) / lampPos
            if (trainStartPos % lampPos == 0) {
                invisibleLamps++
            }

            val visibleLamps = if (lampCount <= invisibleLamps) 0 else lampCount - invisibleLamps
            output.println(visibleLamps)
        }
    }
}

internal class CustomReader(stream: InputStream) {

    private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    init {
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }
}


import java.io.*
import java.util.*

fun main(args: Array<String>) {

    val string1 = "4\n" +
            "10 2 3 7\n" +
            "100 51 51 51\n" +
            "1234 1 100 199\n" +
            "1000000000 1 1 1000000000\n"

    val string2 = "1\n" +
            "989468985 296612298 509835600 762415605\n"

    val stream = ByteArrayInputStream(string1.toByteArray())

    //val input = CustomReader(stream)
    val input = CustomReader(System.`in`)
    val output = PrintWriter(System.out)

    val solver = TaskA()
    solver.solve(1, input, output)
    output.close()
}

internal class TaskA {

    fun solve(testNumber: Int, input: CustomReader, output: PrintWriter) {

        val lines = input.nextInt()

        (0 until lines).forEach { _ ->

            val length = input.nextInt()
            val lampPos = input.nextInt()
            val trainStartPos = input.nextInt()
            val trainEndPos = input.nextInt()

            val lampCount = length / lampPos

            val lessStartPos = (trainStartPos / lampPos) * lampPos
            var invisibleLamps = (trainEndPos - lessStartPos) / lampPos
            if (trainStartPos % lampPos == 0) {
                invisibleLamps++
            }

            val visibleLamps = if (lampCount <= invisibleLamps) 0 else lampCount - invisibleLamps
            output.println(visibleLamps)
        }
    }
}

internal class CustomReader(stream: InputStream) {

    private val reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    init {
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }
}


import java.util.*

fun main(args: Array<String>) = with(Scanner(System.`in`)) {
    repeat(nextInt()) {
        val L = nextLong()
        val v = nextLong()
        val l = nextLong()
        val r = nextLong()

        val x = L / v
        val y = (r / v) - ((l - 1) / v)

        println(x - y)
    }
}


fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val numQueries = readInt()
    val sols = IntArray(numQueries)
    for (query in 0 until numQueries) {
        val (destination, lanternsDistance, left, right) = readInts()
        sols[query] = (left - 1) / lanternsDistance
        val next = (right / lanternsDistance) * lanternsDistance + lanternsDistance
        if (next <= destination) {
            sols[query] += 1
            sols[query] += (destination - next) / lanternsDistance
        }
    }
    print(sols.joinToString(System.lineSeparator()))
}


//Kotlin is also fun!!
import java.util.*
fun main(args: Array<String>) = with(Scanner(System.`in`))
{
    var t=readLine()!!.toInt()
    while(t-->0)
    {
        val (L,v,l,r)= readLine()!!.split(" ").map{it.toInt()}
        println(L/v-r/v+(l-1)/v)
    }
}


//Kotlin is also fun!!
import java.io.BufferedReader
import java.io.InputStreamReader
fun main(args: Array<String>) = with(BufferedReader(InputStreamReader(System.`in`)))
{
    var t=readLine()!!.toInt()
    while(t-->0)
    {
        val (L,v,l,r)= readLine()!!.split(" ").map{it.toInt()}
        println(L/v-r/v+(l-1)/v)
    }
}


//Kotlin is also fun!!
import java.io.*
fun main(args: Array<String>) = with(BufferedReader(InputStreamReader(System.`in`)))
{
    var t=readLine()!!.toInt()
    while(t-->0)
    {
        val (L,v,l,r)= readLine()!!.split(" ").map{it.toInt()}
        println(L/v-r/v+(l-1)/v)
    }
}


import java.io.PrintWriter
import java.util.*

fun main() {
    val inp = Scanner(System.`in`)
    val out = PrintWriter(System.out)

    var t = inp.nextInt()
    while(t-->0){
        val a = LongArray(4)
        for(i in a.indices) {
            a[i]=inp.nextLong()
        }
        if(a[0]<a[2]){
            println(a[0]/a[1]);
            continue
        }
        var gg: Long=0
        gg+=(a[2]-1)/a[1];
        if(a[3]<a[0]) gg+=a[0]/a[1]-a[3]/a[1];
        println(gg);
    }
}


fun main(args: Array<String>) {
    (1..readLine()!!.toInt()).forEach {
        val (pathLen, lightDist, blockStart, blockEnd) = readLine().orEmpty().split(' ').map { it.toInt() }
        val count = pathLen / lightDist - blockEnd / lightDist + (blockStart - 1) / lightDist
        println(count)
    }
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
public static void main(String [] s){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int l = sc.nextInt();
int stolb = sc.nextInt();
int start = sc.nextInt();
int end = sc.nextInt();
int extra = l%stolb==0?1:0;
int extraM = end%stolb==0?1:0;
int extraMM = start%stolb==0?1:0;
int result = ((start-1)/stolb + (l-end)/stolb + extra-extraM)<0?0:(start-1)/stolb + (l-end)/stolb +extra-ex-extraM;
System.out.println(result);
}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
  public static void main(String [] s){
        Scanner sc = new Scanner(System.in);
        int n = Integer.valueOf(sc.nextLine());
        while(n>0){
            int l=sc.nextInt();
            int st=sc.nextInt();
            int start=sc.nextInt();
            int end = sc.nextInt();
            int result=0;
        if(st==1){
            System.out.println(start-1+(l-end));
            }else if(st!=0){
            result +=start/st;
            if(start%st==0){
                result--;
            }
            result+=(l-end)/st;
            if(l%st==0&&end!=l){
                result++;
            }
        System.out.println(result);
        }else{
            System.out.println(0);
        }
        n--;
    }
}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
  public static void main(String [] s){
        Scanner sc = new Scanner(System.in);
        int n = Integer.valueOf(sc.nextLine());
        while(n>0){
            int l=sc.nextInt();
            int st=sc.nextInt();
            int start=sc.nextInt();
            int end = sc.nextInt();
            int result=0;
            if(st==1){
            System.out.println(start-1+(l-end));
            }
            else if(st!=0){
            result +=start/st;
            if(start%st==0){
                result--;
            }
            result+=(l-end-1)/st;
            if(l%st==0&&end!=l){
                result++;
            }
        System.out.println(result);
        }else{
            System.out.println(0);
        }
        n--;
    }
}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
  public static void main(String [] s){
        Scanner sc = new Scanner(System.in);
        int n = Integer.valueOf(sc.nextLine());
        while(n>0){
            int l=sc.nextInt();
            int st=sc.nextInt();
            int start=sc.nextInt();
            int end = sc.nextInt();
            int result = l/st;

            System.out.println(result - (end/st-(start-1)/st));
        n--;
        }
    }
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
public static void main(String [] s){
Scanner sc = new Scanner(System.in);
int ll = sc.nextInt();
while (ll>0){
int l = sc.nextInt();
int stolb = sc.nextInt();
int start = sc.nextInt();
int end = sc.nextInt();
int extra = l%stolb==0?1:0;
int extraM = end%stolb==0?1:0;
int result = ((start-1)/stolb + (l-end)/stolb + extra-extraM)<0?0:(start-1)/stolb + (l-end)/stolb +extra-extraM;
System.out.println(result);
    ll--;
}

}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
public static void main(String [] s){
Scanner sc = new Scanner(System.in);
int l = sc.nextInt();
int stolb = sc.nextInt();
int start = sc.nextInt();
int end = sc.nextInt();
int extra = l%stolb==0?1:0;
int extraM = end%stolb==0?1:0;
int result = ((start-1)/stolb + (l-end)/stolb + extra-extraM)<0?0:(start-1)/stolb + (l-end)/stolb + extra-extraM;
System.out.println(result);
}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
public static void main(String [] s){
Scanner sc = new Scanner(System.in);
int l = sc.nextInt();
int stolb = sc.nextInt();
int start = sc.nextInt();
int end = sc.nextInt();
int extra = l%stolb==0?1:0;
int extraM = end%stolb==0?1:0;
System.out.println((start-1)/stolb + (l-end)/stolb + extra-extraM);
}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
public static void main(String [] s){
Scanner sc = new Scanner(System.in);
int l = sc.nextInt();
int stolb = sc.nextInt();
int start = sc.nextInt();
int end = sc.nextInt();
int extra = l%stolb==0?1:0;
int extraM = end%stolb==0?1:0;
int extraMM = start%stolb==0?1:0;
int result = ((start-1)/stolb + (l-end)/stolb + extra-extraM)<0?0:(start-1)/stolb + (l-end)/stolb +extra-extraMM-extraM;
System.out.println(result);
}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
  public static void main(String [] s){
        Scanner sc = new Scanner(System.in);
        int n = Integer.valueOf(sc.nextLine());
        while(n>0){
            int l=sc.nextInt();
            int st=sc.nextInt();
            int start=sc.nextInt();
            int end = sc.nextInt();
            int result=0;
            result += start/st;
            if(start%st==0){
                result--;
            }
            result+= (l-end)/st;
            if(l%st==0&&st!=1){
                result++;
            }
            System.out.println(result);
            n--;
        }
    }
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
  public static void main(String [] s){
        Scanner sc = new Scanner(System.in);
        int n = Integer.valueOf(sc.nextLine());
        while(n>0){
            int l=sc.nextInt();
            int st=sc.nextInt();
            int start=sc.nextInt();
            int end = sc.nextInt();
            int result=0;
            if(st==1){
            result += start-1 + (l-end);
            System.out.println(result);
             }else if(st!=0){
                result += start/st;
                if(start % st==0){
                    result--;
                }
            result += (l-end)/st;
            if(l%st==0&&(l-end)%st!=0){
                result++;
            }
        System.out.println(result);
        }else{
            System.out.println(0);

        }
        n--;
    }
}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
public static void main(String [] s){
Scanner sc = new Scanner(System.in);
int l = sc.nextInt();
int stolb = sc.nextInt();
int start = sc.nextInt();
int end = sc.nextInt();
int extra = l%stolb==0?1:0;
int extraM = end%stolb==0?1:0;
System.out.println((start-1)/stolb + (int)(l-end-1-stolb+1)/stolb + 1 + extra-extraM);
}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
  public static void main(String [] s){
        Scanner sc = new Scanner(System.in);
        int n = Integer.valueOf(sc.nextLine());
        while(n>0){
            int l=sc.nextInt();
            int st=sc.nextInt();
            int start=sc.nextInt();
            int end = sc.nextInt();
            int result=0;
            if(st!=0){
            for(int i = 1;i<start;i++){
                if(i%st==0){
                    result++;
                }
            }
            for(int j=end+1;j<=l;j++){
                if(j%st==0){
                    result++;
            }
            }
        System.out.println(result);
        }else{
            System.out.println(0);
        }
        n--;
    }
}
}


import java.util.Scanner;
import java.util.*;

public class Triangle{
  public static void main(String [] s){
        Scanner sc = new Scanner(System.in);
        int n = Integer.valueOf(sc.nextLine());
        while(n>0){
            int l=sc.nextInt();
            int st=sc.nextInt();
            int start=sc.nextInt();
            int end = sc.nextInt();
            int result=0;
        if(st!=0){
            result += start/st;
            if(start%st==0){
                result--;
            }
            result+= (l-end)/st;
            if(l%st==0&&st!=1){
                result++;
            }
            System.out.println(result);
        }else{
            System.out.println(0);
        }
            n--;
        }
    }
}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

// author @fire
public class CodeFo {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int t=sc.nextInt();
        for(int ind=0;ind<t;ind++){
            long L=sc.nextLong();
            long v=sc.nextLong();
            long l=sc.nextLong();
            long r=sc.nextLong();
            long lanterns=(long)L/v;
            long count=countDivisibles(l,r,v);
            System.out.println(lanterns-count);

        }

    }

    static long countDivisibles(long A, long B, long M)
    {
        // Add 1 explicitly as A is divisible by M
        if (A % M == 0)
            return (B / M) - (A / M) + 1;

        // A is not divisible by M
        return (B / M) - (A / M);
    }
    static long getSum(long n)
    {
        long sum;

        /* Single line that calculates sum */
        for (sum = 0; n > 0; sum += n % 10,
                n /= 10);

        return sum;
    }

    static int gcd(int a , int b)
    {
        if(b == 0)
            return a;
        return gcd(b , a % b);
    }

}
class Scanner {
    public BufferedReader reader;
    public StringTokenizer st;

    public Scanner(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = reader.readLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            } catch (Exception e) {
                throw (new RuntimeException());
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

class OutputWriter {
    BufferedWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new BufferedWriter(new OutputStreamWriter(stream));
    }

    public void print(int i) throws IOException {
        writer.write(i);
    }

    public void print(String s) throws IOException {
        writer.write(s);
    }

    public void print(char[] c) throws IOException {
        writer.write(c);
    }

    public void close() throws IOException {
        writer.close();
    }

}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

// author @ire
public class C {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int t=sc.nextInt();
        for(int ind=0;ind<t;ind++){
            long L=sc.nextLong();
            long v=sc.nextLong();
            long l=sc.nextLong();
            long r=sc.nextLong();
            long lanterns=(long)L/v;
           // System.out.println(lanterns);
            long count=0;
            if(l==r && l%v==0)
                count++;
            if(l!=r){
                if(l%v!=0 && r%v!=0){
                    count+=(r-l)/v;
                }
                else {
                    count+=(r-l)/v;
                    count++;
                }
            }
            System.out.println(lanterns-count);
        }

    }

    static long getSum(long n)
    {
        long sum;

        /* Single line that calculates sum */
        for (sum = 0; n > 0; sum += n % 10,
                n /= 10);

        return sum;
    }

    static int gcd(int a , int b)
    {
        if(b == 0)
            return a;
        return gcd(b , a % b);
    }

}
class Scanner {
    public BufferedReader reader;
    public StringTokenizer st;

    public Scanner(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = reader.readLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            } catch (Exception e) {
                throw (new RuntimeException());
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

class OutputWriter {
    BufferedWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new BufferedWriter(new OutputStreamWriter(stream));
    }

    public void print(int i) throws IOException {
        writer.write(i);
    }

    public void print(String s) throws IOException {
        writer.write(s);
    }

    public void print(char[] c) throws IOException {
        writer.write(c);
    }

    public void close() throws IOException {
        writer.close();
    }

}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

// author @fire
public class Code{
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int t=sc.nextInt();
        for(int ind=0;ind<t;ind++){
            long L=sc.nextLong();
            long v=sc.nextLong();
            long l=sc.nextLong();
            long r=sc.nextLong();
            long lanterns=(long)L/v;
           // System.out.println(lanterns);
            long count=0;
            for(long i=v;i<=L;i+=v){
                if(i>=l && i<=r)
                    count++;

            }
            System.out.println(lanterns-count);
        }

    }

    static long getSum(long n)
    {
        long sum;

        /* Single line that calculates sum */
        for (sum = 0; n > 0; sum += n % 10,
                n /= 10);

        return sum;
    }

    static int gcd(int a , int b)
    {
        if(b == 0)
            return a;
        return gcd(b , a % b);
    }

}
class Scanner {
    public BufferedReader reader;
    public StringTokenizer st;

    public Scanner(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = reader.readLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            } catch (Exception e) {
                throw (new RuntimeException());
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

class OutputWriter {
    BufferedWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new BufferedWriter(new OutputStreamWriter(stream));
    }

    public void print(int i) throws IOException {
        writer.write(i);
    }

    public void print(String s) throws IOException {
        writer.write(s);
    }

    public void print(char[] c) throws IOException {
        writer.write(c);
    }

    public void close() throws IOException {
        writer.close();
    }

}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

// author @fire
public class c {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int t=sc.nextInt();
        for(int ind=0;ind<t;ind++) {
            long L = sc.nextLong();
            long v = sc.nextLong();
            long l = sc.nextLong();
            long r = sc.nextLong();
            long lanterns = (long) L / v;
            // System.out.println(lanterns);
            long count = 0;
            if (r == L && l == 1)
                System.out.println(0);
            else {
                for (long i = v; i <= L; i += v) {
                    if (i >= l && i <= r)
                        count++;
                }
                System.out.println(lanterns - count);
            }
        }

    }

    static long getSum(long n)
    {
        long sum;

        /* Single line that calculates sum */
        for (sum = 0; n > 0; sum += n % 10,
                n /= 10);

        return sum;
    }

    static int gcd(int a , int b)
    {
        if(b == 0)
            return a;
        return gcd(b , a % b);
    }

}
class Scanner {
    public BufferedReader reader;
    public StringTokenizer st;

    public Scanner(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = reader.readLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            } catch (Exception e) {
                throw (new RuntimeException());
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

class OutputWriter {
    BufferedWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new BufferedWriter(new OutputStreamWriter(stream));
    }

    public void print(int i) throws IOException {
        writer.write(i);
    }

    public void print(String s) throws IOException {
        writer.write(s);
    }

    public void print(char[] c) throws IOException {
        writer.write(c);
    }

    public void close() throws IOException {
        writer.close();
    }

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

	public class ECPC {
		static int mod = (int) (1e9 + 7);
		public static void main(String[] args) throws NumberFormatException, IOException {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        //BufferedReader br = new BufferedReader(new FileReader("K.in"));
			PrintWriter out  = new PrintWriter(System.out);
			Scanner sc = new Scanner(System.in);
			int t = Integer.parseInt(br.readLine());
			while(t-- >0)
			{
				StringTokenizer st = new StringTokenizer(br.readLine());
				int L = Integer.parseInt(st.nextToken());
				int v = Integer.parseInt(st.nextToken());
				int l = Integer.parseInt(st.nextToken());
				int r = Integer.parseInt(st.nextToken());
				int res = 0;
				if(v==1)
					{
					res+=L/v + 1;
					res-=(r-l) + 2;
					}

				else
				{

					res+=L/v;

					res-= (int) Math.ceil((r-l)/(double)v);
					if(r%v==0 && l%v==0)
						res-=1;

				}
				out.println(res);
			}

	out.flush();
	}

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

	public class ECPC {
		static int mod = (int) (1e9 + 7);
		public static void main(String[] args) throws NumberFormatException, IOException {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        //BufferedReader br = new BufferedReader(new FileReader("K.in"));
			PrintWriter out  = new PrintWriter(System.out);
			Scanner sc = new Scanner(System.in);
			int t = Integer.parseInt(br.readLine());
			while(t-- >0)
			{
				StringTokenizer st = new StringTokenizer(br.readLine());
				int L = Integer.parseInt(st.nextToken());
				int v = Integer.parseInt(st.nextToken());
				int l = Integer.parseInt(st.nextToken());
				int r = Integer.parseInt(st.nextToken());

				out.println(L/v - r/v + (l-1)/v);
			}

	out.flush();
	}

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

	public class ECPC {
		static int mod = (int) (1e9 + 7);
		public static void main(String[] args) throws NumberFormatException, IOException {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        //BufferedReader br = new BufferedReader(new FileReader("K.in"));
			PrintWriter out  = new PrintWriter(System.out);
			Scanner sc = new Scanner(System.in);
			int t = Integer.parseInt(br.readLine());
			while(t-- >0)
			{
				StringTokenizer st = new StringTokenizer(br.readLine());
				int L = Integer.parseInt(st.nextToken());
				int v = Integer.parseInt(st.nextToken());
				int l = Integer.parseInt(st.nextToken());
				int r = Integer.parseInt(st.nextToken());
				int res = 0;
				res+=L/v ;
				if(r%v == 0 && l%v ==0)
					res-=(r-l)/v + 1;
				else if(r%v == 0 || l%v ==0)
					res-=(r-l)/v;
				else
					res-=(r-l)/v ;

				out.println(res);
			}

	out.flush();
	}

}


// package com.sri.java.codeforces;

import java.util.Scanner;

/**
 * @author Sri Mouli
 * Date: 13/11/18/11/2018 11:31 PM
 * Copyright © 2018 MyKaarma. All rights reserved.
 */
public class VovaAndTrain_1066A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Long t = in.nextLong();
        while(t!=0){
            Long ans = 0l;
            Long destination = in.nextLong();
            Long latentLoc = in.nextLong();
            Long standingTrainStart = in.nextLong();
            Long standingTrainEnd = in.nextLong();
            ans = destination/latentLoc - standingTrainEnd/latentLoc + (standingTrainStart-1)/latentLoc;
            System.out.println(ans);
            t--;
        }
    }

}


package com.sri.java.codeforces;

import java.util.Scanner;

/**
 * @author Sri Mouli
 * Date: 13/11/18/11/2018 11:31 PM
 * Copyright © 2018 MyKaarma. All rights reserved.
 */
public class VovaAndTrain_1066A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Long t = in.nextLong();
        while(t!=0){
            Long ans = 0l;
            Long destination = in.nextLong();
            Long latentLoc = in.nextLong();
            Long standingTrainStart = in.nextLong();
            Long standingTrainEnd = in.nextLong();
            ans = destination/latentLoc - standingTrainEnd/latentLoc + (standingTrainStart-1)/latentLoc;
            System.out.println(ans);
            t--;
        }
    }

}


public class VovaAndTrain_1066A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Long t = in.nextLong();
        while(t!=0){
            Long ans = 0l;
            Long destination = in.nextLong();
            Long latentLoc = in.nextLong();
            Long standingTrainStart = in.nextLong();
            Long standingTrainEnd = in.nextLong();
            ans = destination/latentLoc - standingTrainEnd/latentLoc + (standingTrainStart-1)/latentLoc;
            System.out.println(ans);
            t--;
        }
    }

}


import java.util.*;

public class ContestA {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while(t-->0) {
			long L = in.nextInt();
			long v = in.nextInt();
			long l = in.nextInt();
			long r = in.nextInt();
			long c = (L/v);
			c -= (r/v -l/v);
			if(l%v==0)c--;
			System.out.println(c);
		}
		in.close();
	}
}


import java.util.*;

public class ContestA {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while(t-->0) {
			long L = in.nextInt();
			long v = in.nextInt();
			long l = in.nextInt();
			long r = in.nextInt();
			long c = (L/v)-((r-l+1)/v);
			if(c!=0 && l<=v && r>=v) c--;
			System.out.println(c);
		}
		in.close();
	}
}


import java.util.*;

public class ContestA {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while(t-->0) {
			long L = in.nextInt();
			long v = in.nextInt();
			long l = in.nextInt();
			long r = in.nextInt();
			long c = (L/v)-((r-l+1)/v);
			if(((r-l+1)/v)==0 && l<=v && r>=v) c--;
			System.out.println(c);
		}
		in.close();
	}
}


import java.util.Scanner;

public class train {
    public static void main(String[] args) {
        Scanner cin=null;

        cin=new Scanner(System.in);

        int t = cin.nextInt();
        while(t-- >0){
            int n = cin.nextInt();
            int v = cin.nextInt();
            int l = cin.nextInt();
            int r = cin.nextInt();
            int res = (n-r) / v + (l-1)/v;
            System.out.println(res);

        }

    }

}


import java.io.PrintWriter;
import java.util.Scanner;

public class train {
    public static void main(String[] args) {
        Scanner cin=null;

        cin=new Scanner(System.in);
        int t = cin.nextInt();
        while(t-- >0){
            int n = cin.nextInt();
            int v = cin.nextInt();
            int l = cin.nextInt();
            int r = cin.nextInt();
            int res = (n -(r-l) - 1/v);

            System.out.println(res);

        }

    }

}


import java.util.Scanner;

public class train {
    public static void main(String[] args) {
        Scanner cin=null;

        cin=new Scanner(System.in);
        int t = cin.nextInt();
        while(t-- >0){
            int n = cin.nextInt();
            int v = cin.nextInt();
            int l = cin.nextInt();
            int r = cin.nextInt();
            int res = (n + l -r - 1) /v;
            System.out.println(res);

        }
    }

}


import java.util.Scanner;

public class train {
    public static void main(String[] args) {
        Scanner cin=null;

        cin=new Scanner(System.in);

        int t = cin.nextInt();
        while(t-- >0){
            int n = cin.nextInt();
            int v = cin.nextInt();
            int l = cin.nextInt();
            int r = cin.nextInt();
            int res = (n /v)- (r/v) + (l-1)/v;
            System.out.println(res);

        }

    }

}


import java.util.Scanner;

public class train {
    public static void main(String[] args) {
        Scanner cin=null;

        cin=new Scanner(System.in);
        PrintWriter cout=new PrintWriter(System.out,true);
        StringBuilder print=new StringBuilder();

        int t = cin.nextInt();
        while(t-- >0){
            int n = cin.nextInt();
            int v = cin.nextInt();
            int l = cin.nextInt();
            int r = cin.nextInt();
            int res = (n-r)/v + (l-1)/v;
            System.out.println(res);

        }
    }

}


import java.util.Scanner;

public class problemA {
	public static void main (String []a) {
		Scanner in =new Scanner (System.in);
		int queries=in.nextInt();
		for (int i=0;i<queries;i++) {
			long destination=in.nextLong();
			long vi=in.nextLong();
			long l =in.nextLong();
			long r=in.nextLong();
			long numofv =destination/vi;
			long z = l%vi;
			long start=l-z;
			long f=start/vi;
			long h= r%vi;
			long h1=h+r;
			long end = h1/vi;
			long s = end-f-1;
			if (h==0&&r<=destination) {
				s++;
			}
			if (z==0&&l<=destination) {
				s++;
			}
			if (end ==f||numofv-s<0) {
				System.out.println("0");
			}
			else {
			numofv-=s;
			System.out.println(numofv);}

		}

	}

}


import java.util.Scanner;

public class problemA {
	public static void main (String []a) {
		Scanner in =new Scanner (System.in);
		int queries=in.nextInt();
		for (int i=0;i<queries;i++) {
			long destination=in.nextLong();
			long vi=in.nextLong();
			long l =in.nextLong();
			long r=in.nextLong();
			long numofv =destination/vi;
			long z = l%vi;
			long start=l-z;
			long f=start/vi;
			long h= r%vi;
			long h1=h+r;
			long end = h1/vi;
			long s = end-f-1;
			if (h==0&&r<=destination) {
				s++;
			}
			if (z==0&&l<=destination) {
				s++;
			}
			if (end ==f) {
				System.out.println("0");
			}
			else {
			numofv-=s;
			System.out.println(numofv);}

		}

	}

}


import java.util.Scanner;

public class problemA {
	public static void main (String []a) {
		Scanner in =new Scanner (System.in);
		int queries=in.nextInt();
		for (int i=0;i<queries;i++) {
			long destination=in.nextLong();
			long vi=in.nextLong();
			long l =in.nextLong();
			long r=in.nextLong();
			long numofv =destination/vi;
			long z = l%vi;
			long start=l-z;
			long f=start/vi;
			long h= r%vi;

			long h1=h+r;
			while (h1>destination) {
				h1=-h+r;
			}
			long end = h1/vi;
			long s = end-f-1;
			if (h==0&&r<=destination) {
				s++;
			}
			if (z==0&&l<=destination) {
				s++;
			}
			if (end ==f||numofv-s<0) {
				System.out.println("0");
			}
			else {
			numofv-=s;
			System.out.println(numofv);}

		}

	}

}


import java.util.Scanner;

public class problemA {
	public static void main (String []a) {
		Scanner in =new Scanner (System.in);
		int queries=in.nextInt();
		for (int i=0;i<queries;i++) {
			long destination=in.nextLong();
			long vi=in.nextLong();
			long l =in.nextLong();
			long r=in.nextLong();
			long numofv =0;
			long nums=l/vi;
			if (l%vi==0) {
				nums--;
			}
			long numg= r/vi;
			numg++;
			numofv+=nums;
			long z =destination/vi;
			long add = z-numg+1;
			numofv+=add;
			System.out.println(numofv);

		}

	}

}


import java.util.Scanner;

public class problemA {
	public static void main (String []a) {
		Scanner in =new Scanner (System.in);
		int queries=in.nextInt();
		for (int i=0;i<queries;i++) {
			long destination=in.nextLong();
			long vi=in.nextLong();
			long l =in.nextLong();
			long r=in.nextLong();
			long numofv =destination/vi;
			long z = l%vi;
			long start=l-z;
			long f=start/vi;
			long h= r%vi;
			long h1=h+r;
			long end = h1/vi;
			long s = end-f-1;
			if (h==0) {
				s++;
			}
			if (z==0) {
				s++;
			}
			if (end ==f) {
				System.out.println("0");
			}
			else {
			numofv-=s;
			System.out.println(numofv);}

		}

	}

}


import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Compete {
    static class FastReader {
        private BufferedReader br;
        private StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static long divisors(long L, long v){
        long count=0;
        for(int i=1;i<=L;i++){
            if(i%v==0){
                count+=1;
            }
        }
        return count;
    }
    public static void main(String[] args) throws Exception {
        try{
            FastReader sc = new FastReader();
            int T = sc.nextInt();
            while(T!=0){
                int L = sc.nextInt();
                int v = sc.nextInt();
                int  l = sc.nextInt();
                int r = sc.nextInt();
                int ans = L/v-r/v+l/v;
                if(L%v==0){
                    ans-=1;
                }
                System.out.println(ans);

            }
        }
        catch(Exception e){

        }
    }
}


import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Compete {
    static class FastReader {
        private BufferedReader br;
        private StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static long divisors(long L, long v){
        long count=0;
        for(int i=1;i<=L;i++){
            if(i%v==0){
                count+=1;
            }
        }
        return count;
    }
    public static void main(String[] args) throws Exception {
        try{
            FastReader sc = new FastReader();
            int T = sc.nextInt();
            while(T-->0){
                int L = sc.nextInt(), v = sc.nextInt(), l = sc.nextInt(), r = sc.nextInt();

                int ans = L/v - r/v + l/v;
                if(l%v==0)
                    ans--;
                System.out.println(ans);
            }
        }
        catch(Exception e){

        }
    }
}


import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Compete {
    static class FastReader {
        private BufferedReader br;
        private StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static long divisors(long L, long v){
        long count=0;
        for(int i=1;i<=L;i++){
            if(i%v==0){
                count+=1;
            }
        }
        return count;
    }
    public static void main(String[] args) throws Exception {
        try{
            FastReader sc = new FastReader();
            int T = sc.nextInt();
            while(T!=0){
                long L = sc.nextInt();
                long v = sc.nextInt();
                int  l = sc.nextInt();
                long r = sc.nextInt();
                long count=divisors(L,v);
                long bcount=0;
                if(v==l){
                    System.out.println("0");
                }
                else{
                    for(int i=l;i<=r;i++){
                        if(i%v==0){
                            bcount+=1;
                        }
                    }
                    System.out.println(Math.abs(count-bcount));
                }
            }
        }
        catch(Exception e){

        }
    }
}


import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Compete {
    static class FastReader {
        private BufferedReader br;
        private StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static long divisors(long L, long v){
        long count=0;
        for(int i=1;i<=L;i++){
            if(i%v==0){
                count+=1;
            }
        }
        return count;
    }
    public static void main(String[] args) throws Exception {
        try{
            FastReader sc = new FastReader();
            int T = sc.nextInt();
            while(T!=0){
                long L = sc.nextInt();
                long v = sc.nextInt();
                int  l = sc.nextInt();
                long r = sc.nextInt();
                long count=0;
                long bcount=0;
                if(v==l){
                    System.out.println("0");
                }
                else{
                    count=divisors(L,v);
                    for(int i=l;i<=r;i++){
                        if(i%v==0){
                            bcount+=1;
                        }
                    }
                    System.out.println(Math.abs(count-bcount));
                }
            }
        }
        catch(Exception e){

        }
    }
}


package ContestDiv3;

import java.util.Scanner;

public class task1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int arr [] = new int[n];
        for(int i = 0; i < n ;i ++) {

            int azaiter = 0;

            int L = in.nextInt();
            int v = in.nextInt();
            int l = in.nextInt();
            int r = in.nextInt();

            int sumAz = r / v - l / v;
            if (r % v == 0 && l % v == 0) {
                azaiter = 1;
            }
            int res = L / v - sumAz - azaiter;
            System.out.println(res);
            }

        }
}


import java.util.Scanner;

public class task1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int arr [] = new int[n];
        for(int i = 0; i < n ;i ++) {

            int L = in.nextInt();
            int v = in.nextInt();
            int l = in.nextInt();
            int r = in.nextInt();

            int sumAz = r / v - (l - 1)/ v;

            int res = L / v - sumAz;
            System.out.println(res);
            }

        }
}


package ContestDiv3;

import java.util.Scanner;

public class task1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int arr [] = new int[n];
        for(int i = 0; i < n ;i ++) {

            int azaiter = 0;

            int L = in.nextInt();
            int v = in.nextInt();
            int l = in.nextInt();
            int r = in.nextInt();

            int sumAz = r / v - l / v;
            if (r % v == 0 || l % v == 0) {
                azaiter = 1;
            }
            int res = L / v - sumAz - azaiter;
            arr[i] = res;
            }

        for (int i = 0; i <n ; i++) {
            System.out.println(arr[i]);
        }
        }
}


package ContestDiv3;

import java.util.Scanner;

public class task1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int arr [] = new int[n];
        for(int i = 0; i < n ;i ++) {

            int azaiter = 0;

            int L = in.nextInt();
            int v = in.nextInt();
            int l = in.nextInt();
            int r = in.nextInt();

            int sumAz = r / v - l / v;
            if (r % v == 0 && l % v == 0) {
                azaiter = 1;
            }
            int res = L / v - sumAz - azaiter;
            arr[i] = res;
            }

        for (int i = 0; i <n ; i++) {
            System.out.println(arr[i]);
        }
        }
}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        //Scanner sc = new Scanner();
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();

    }

    void solve(PrintWriter out, Reader in) throws IOException{
        int n = in.nextInt();

        int target,v,l,r;
        for(int i=0 ;i<n ;i++){
            target = in.nextInt();
            v = in.nextInt();
            l = in.nextInt();
            r = in.nextInt();

            if((r-l+1)/v==0 && (l/v!=r/v || (l==r && l%v==0)) ) System.out.println(target/v-1);
            else System.out.println(target/v-(r-l+1)/v);

        }
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static class Scanner  {
        BufferedReader br;
        StringTokenizer st;

        public Scanner()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        //Scanner sc = new Scanner();
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();

    }

    void solve(PrintWriter out, Reader in) throws IOException{
        int n = in.nextInt();

        int target,v,l,r;
        for(int i=0 ;i<n ;i++){
            target = in.nextInt();
            v = in.nextInt();
            l = in.nextInt();
            r = in.nextInt();

            if((r-l)/v==0 && (l/v!=r/v || (l==r && l%v==0)) ) System.out.println(target/v-1);
            else System.out.println(target/v-(r-l+1)/v);

        }
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static class Scanner  {
        BufferedReader br;
        StringTokenizer st;

        public Scanner()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        //Scanner sc = new Scanner();
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();

    }

    void solve(PrintWriter out, Reader in) throws IOException{
        int n = in.nextInt();

        int target,v,l,r;
        for(int i=0 ;i<n ;i++){
            target = in.nextInt();
            v = in.nextInt();
            l = in.nextInt();
            r = Math.min(in.nextInt(),target);
            if(r<l) {System.out.println(target/v);continue;}
            if((r-l+1)/v==0 && (l/v!=r/v || (l==r && l%v==0)) ) System.out.println(target/v-1);
            else System.out.println(target/v-(r-l+1)/v);

        }
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static class Scanner  {
        BufferedReader br;
        StringTokenizer st;

        public Scanner()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        //Scanner sc = new Scanner();
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();

    }

    void solve(PrintWriter out, Reader in) throws IOException{
        int n = in.nextInt();

        int target,v,l,r;
        int ans=0;
        for(int i=0 ;i<n ;i++){
            target = in.nextInt();
            v = in.nextInt();
            l = in.nextInt();
            r = Math.min(in.nextInt(),target);

            if(r<l) {System.out.println(target/v);continue;}
            ans = target/v - r/v + (l-1)/v;
            System.out.println(ans);

        }
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static class Scanner  {
        BufferedReader br;
        StringTokenizer st;

        public Scanner()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        //Scanner sc = new Scanner();
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();

    }

    void solve(PrintWriter out, Reader in) throws IOException{
        int n = in.nextInt();

        int target,v,l,r;
        for(int i=0 ;i<n ;i++){
            target = in.nextInt();
            v = in.nextInt();
            l = in.nextInt();
            r = in.nextInt();

            if((r-l)/v==0 && (l/v!=r/v || (l==r && l%v==0)) ) System.out.println(target/v-1);
            else System.out.println(target/v-(r-l)/v - (v==1 ? 1 :0));

        }
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static class Scanner  {
        BufferedReader br;
        StringTokenizer st;

        public Scanner()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        //Scanner sc = new Scanner();
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();

    }

    void solve(PrintWriter out, Reader in) throws IOException{
        int n = in.nextInt();

        int target,v,l,r;
        for(int i=0 ;i<n ;i++){
            target = in.nextInt();
            v = in.nextInt();
            l = in.nextInt();
            r = Math.min(in.nextInt(),target);

            if((r-l+1)/v==0 && (l/v!=r/v || (l==r && l%v==0)) ) System.out.println(target/v-1);
            else System.out.println(target/v-(r-l+1)/v);

        }
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static class Scanner  {
        BufferedReader br;
        StringTokenizer st;

        public Scanner()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


package codeforce;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class VovaAndTrain {
	public static void main(String[] args) throws IOException {
		BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
		long testNum = Long.parseLong(bi.readLine());
		while(testNum>0) {
			String[] strNums;
			strNums = bi.readLine().split("\\s");
			long d = Long.parseLong(strNums[0]);
			long v = Long.parseLong(strNums[1]);
			long l = Long.parseLong(strNums[2]);
			long r = Long.parseLong(strNums[3]);

			System.out.println((d/v)-((r/v)-((l-1)/v)));
			testNum--;

		}

	}

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class VovaAndTrain {
	public static void main(String[] args) throws IOException {
		BufferedReader bi = new BufferedReader(new FileReader("input.txt"));
		long testNum = Long.parseLong(bi.readLine());
		while(testNum>0) {
			String[] strNums;
			strNums = bi.readLine().split("\\s");
			long d = Long.parseLong(strNums[0]);
			long v = Long.parseLong(strNums[1]);
			long l = Long.parseLong(strNums[2]);
			long r = Long.parseLong(strNums[3]);

			System.out.println((d/v)-((r/v)-((l-1)/v)));
			testNum--;

		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class VovaAndTrain {
	public static void main(String[] args) throws IOException {
		BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
		long testNum = Long.parseLong(bi.readLine());
		while(testNum>0) {
			String[] strNums;
			strNums = bi.readLine().split("\\s");
			long d = Long.parseLong(strNums[0]);
			long v = Long.parseLong(strNums[1]);
			long l = Long.parseLong(strNums[2]);
			long r = Long.parseLong(strNums[3]);

			System.out.println((d/v)-((r/v)-((l-1)/v)));
			testNum--;

		}

	}

}


/*package whatever //do not write package name here */

import java.util.*;

public class GFG {
	public static void main (String[] args) {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();

	for(int i=0;i<t;i++)
	{
	   int l= sc.nextInt();
	   int v=sc.nextInt();
	    int a= sc.nextInt();
	   int b=sc.nextInt();
	  // if(v<l)
	 //{
	     int a1=v*((a/v)+(a%v==0?0:1));
	  //System.out.println(a1);
	int b1=v*((b/v)+(b%v==0?0:-1));
	//System.out.println(b1);
	int q=0;
	if((b1-a1)>0)
	  q=((b1-a1)/v);
	 // System.out.println(q);
	  if(q>0)
	  q--;
	 int q1=l/v;
	// System.out.println(q1);
	 int q2=0;
	 if(b1>=a&&b1!=a1)
	   q2++;
	   if(a1<=b&&b1!=a1)
	   q2++;
	  else{
	      if((b1==a1)&&(b1>=a&&b1<=b))
	      q2++;
	  }
	  // System.out.println(q2);
	 System.out.println(q1-q-q2);

	 //}
	// else
	 // System.out.println(0);
	}

	}
}


/*package whatever //do not write package name here */

import java.util.*;

public class GFG {
	public static void main (String[] args) {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();

	for(int i=0;i<t;i++)
	{
	   int l= sc.nextInt();
	   int v=sc.nextInt();
	    int a= sc.nextInt();
	   int b=sc.nextInt();
	  // if(v<l)
	 //{
	     int a1=v*((a/v)+(a%v==0?0:1));
	  //System.out.println(a1);
	int b1=v*(b/v);
	//System.out.println(b1);
	int q=0;
	if((b1-a1)>0)
	  q=((b1-a1)/v);
	 // System.out.println(q);
	  if(q>0)
	  q--;
	 int q1=l/v;
	// System.out.println(q1);
	 int q2=0;
	 if(b1>=a&&b1!=a1)
	   q2++;
	   if(a1<=b&&b1!=a1)
	   q2++;
	  else{
	      if((b1==a1)&&(b1>=a&&b1<=b))
	      q2++;
	  }
	  // System.out.println(q2);
	 System.out.println(q1-q-q2);

	 //}
	// else
	 // System.out.println(0);
	}

	}
}


/*package whatever //do not write package name here */

import java.util.*;

public class GFG {
	public static void main (String[] args) {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();

	for(int i=0;i<t;i++)
	{
	   int l= sc.nextInt();
	   int v=sc.nextInt();
	    int a= sc.nextInt();
	   int b=sc.nextInt();
	 a+=a%v;
	 b-=b%v;
	 int q=((b-a)/v)-1;
	 int q1=l/v;
	 int q2=0;
	 if(b%v==0)
	   q2++;
	   if(a%v==0)
	   q2++;
	 System.out.println(q1-q-q2);
	}

	}
}


/*package whatever //do not write package name here */

import java.util.*;

public class GFG {
	public static void main (String[] args) {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();

	for(int i=0;i<t;i++)
	{
	   int l= sc.nextInt();
	   int v=sc.nextInt();
	    int a= sc.nextInt();
	   int b=sc.nextInt();
	 a+=a%v;
	 b-=b%v;
	 int q=((b-a)/v)-1;
	 int q1=l/v;
	 int q2=0;
	 if((b-a)>0)
	   q2++;
	  else{
	      if(b%v==0)
	      q2++;
	  }
	 System.out.println(q1-q-q2);
	}

	}
}


/*package whatever //do not write package name here */

import java.util.*;

public class GFG {
	public static void main (String[] args) {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();

	for(int i=0;i<t;i++)
	{
	   int l= sc.nextInt();
	   int v=sc.nextInt();
	    int a= sc.nextInt();
	   int b=sc.nextInt();
	 int a1=a+a%v;
	int b1=b-b%v;
	int q=0;
	if((b1-a1)>0)
	  q=((b1-a1)/v);
	  if(q>0)
	  q--;
	 int q1=l/v;
	 int q2=0;
	 if(b1>=a&&b1!=a1)
	   q2++;
	   if(a1<=b&&b1!=a1)
	   q2++;
	  else{
	      if((b1==a1)&&(b1>=a&&b1<=b))
	      q2++;
	  }
	 System.out.println(q1-q-q2);
	}

	}
}


/*package whatever //do not write package name here */

import java.util.*;

public class GFG {
	public static void main (String[] args) {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();

	for(int i=0;i<t;i++)
	{
	   int l= sc.nextInt();
	   int v=sc.nextInt();
	    int a= sc.nextInt();
	   int b=sc.nextInt();
	   if(v<=l)
	 {int a1=a+a%v;
	int b1=b-b%v;
	int q=0;
	if((b1-a1)>0)
	  q=((b1-a1)/v);
	  if(q>0)
	  q--;
	 int q1=l/v;
	 int q2=0;
	 if(b1>=a&&b1!=a1)
	   q2++;
	   if(a1<=b&&b1!=a1)
	   q2++;
	  else{
	      if((b1==a1)&&(b1>=a&&b1<=b))
	      q2++;
	  }
	 System.out.println(q1-q-q2);}
	 else
	  System.out.println(0);
	}

	}
}


/*package whatever //do not write package name here */

import java.util.*;

public class GFG {
	public static void main (String[] args) {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();

	for(int i=0;i<t;i++)
	{
	   int l= sc.nextInt();
	   int v=sc.nextInt();
	    int a= sc.nextInt();
	   int b=sc.nextInt();
	   if(v<l)
	 {int a1=a+a%v;
	int b1=b-b%v;
	int q=0;
	if((b1-a1)>0)
	  q=((b1-a1)/v);
	  if(q>0)
	  q--;
	 int q1=l/v;
	 int q2=0;
	 if(b1>=a&&b1!=a1)
	   q2++;
	   if(a1<=b&&b1!=a1)
	   q2++;
	  else{
	      if((b1==a1)&&(b1>=a&&b1<=b))
	      q2++;
	  }
	 System.out.println(q1-q-q2);}
	 else
	  System.out.println(0);
	}

	}
}


//6000 KB memory
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main  //main class
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
 ///////////////////////////////////////////////////////////////////////////main
    public static void main(String[] args)
    {
        FastReader in=new FastReader();
       int t=in.nextInt();
        for (int i = 0; i < t; i++) {
            long path=in.nextInt(),cc=in.nextInt(),p=in.nextInt(),n=in.nextInt();
            long newp=n-p;
            long nf=path/cc;
            if(cc%p==0)nf--;

            System.out.println(Math.max((nf-((newp+1)/cc)),0));
        }
    }
}


//6000 KB memory
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main  //main class
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
 ///////////////////////////////////////////////////////////////////////////main
    public static void main(String[] args)
    {
        FastReader in=new FastReader();
       int t=in.nextInt();
        for (int i = 0; i < t; i++) {
            long path=in.nextInt(),cc=in.nextInt(),p=in.nextInt(),n=in.nextInt();

            System.out.println(path/cc+(n/cc-p/cc));
        }
    }
}