using System;
using System.Collections.Generic;
namespace soutez1
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			List<string[]> seznamy = new List<string[]>();
			for( int a=0; a<n; a++)
			{
				string[] cisla = Console.ReadLine().Split();
				seznamy.Add(cisla);
			}

			for( int a=0; a<n; a++)
			{
				int L = int.Parse(seznamy[a][0]);
				int v = int.Parse(seznamy[a][1]);
				int zacatek = int.Parse(seznamy[a][2]);
				int konec = int.Parse(seznamy[a][3]);
				int odecist = konec/v - zacatek/v + 1;
				if (zacatek%v != 0)
				{
					odecist--;
				}
				int vysledek = (L / v) - odecist;
				Console.WriteLine(vysledek);

			}

		}

	}
}
			/*int n = int.Parse(Console.ReadLine());
			string[] prvni = Console.ReadLine().Split();
			int zacatek = int.Parse(prvni[0]);
			int konec = int.Parse(prvni[1]);

			for(int a=1; a<n; a++)
			{
				string[] cisla = Console.ReadLine().Split();
				if( zacatek<int.Parse(cisla[0]))
				{
					zacatek = int.Parse(cisla[0]);
				}
				if( konec > int.Parse(cisla[1]))
				{
					konec = int.Parse(cisla[1]);
				}
			}
			if(zacatek> konec)
			{
				Console.WriteLine(0);
			}
			else
			{
				Console.WriteLine(konec-zacatek);
			}*/

			/*int n = int.Parse(Console.ReadLine());
			string[] cisla = Console.ReadLine().Split();

			int maximalni = 0;
			int aktualni = 1;

			for(int a=0; a+1<cisla.Length; a++)
			{
				if(int.Parse(cisla[a]) *2 >= int.Parse(cisla[a+1]))
				{
					aktualni++;
				}
				else
				{
					if(aktualni > maximalni)
					{
						maximalni = aktualni;

					}
					aktualni = 1;
				}
			}
			if(aktualni > maximalni)
			{
				maximalni = aktualni;

			}
			Console.WriteLine(maximalni); */

		/*
			int pocet = int.Parse(prvni[0]);
			int kolikrat = int.Parse(prvni[1]);
			string retezec = Console.ReadLine();

			string vysledek = "";

			for(int a=1; a<retezec.Length; a++)
			{
				if(retezec[a]== retezec[0])
				{
					bool c = true;
					for( int b = 0; a+b<retezec.Length; b++)
					{
						if(retezec[a+b] != retezec[b])
						{
							c = false;
						}
					}
					if(c)
					{
						int aktualnipocet =1;
						string vocas = retezec.Substring(retezec.Length-a);
						//string
						vysledek = retezec;
						while(aktualnipocet<kolikrat)
						{
							vysledek = vysledek+ vocas;
							aktualnipocet++;
						}
						Console.WriteLine (vysledek);
						return;
					}
				}
			}

			for(int a=0; a<kolikrat; a++)
			{
				vysledek = vysledek+retezec;
			}
			Console.WriteLine (vysledek);
			*/


using System;
using System.Collections.Generic;
namespace soutez1
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			List<string[]> seznamy = new List<string[]>();
			for( int a=0; a<n; a++)
			{
				string[] cisla = Console.ReadLine().Split();
				seznamy.Add(cisla);
			}

			for( int a=0; a<n; a++)
			{
				int L = int.Parse(seznamy[a][0]);
				int v = int.Parse(seznamy[a][1]);
				int zacatek = int.Parse(seznamy[a][2]);
				int konec = int.Parse(seznamy[a][3]);
				int odecist = konec/v - zacatek/v + 1;
				if (zacatek%v != 0)
				{
					odecist++;
				}
				int vysledek = (L / v) - odecist;
				Console.WriteLine(vysledek);

			}

		}

	}
}
			/*int n = int.Parse(Console.ReadLine());
			string[] prvni = Console.ReadLine().Split();
			int zacatek = int.Parse(prvni[0]);
			int konec = int.Parse(prvni[1]);

			for(int a=1; a<n; a++)
			{
				string[] cisla = Console.ReadLine().Split();
				if( zacatek<int.Parse(cisla[0]))
				{
					zacatek = int.Parse(cisla[0]);
				}
				if( konec > int.Parse(cisla[1]))
				{
					konec = int.Parse(cisla[1]);
				}
			}
			if(zacatek> konec)
			{
				Console.WriteLine(0);
			}
			else
			{
				Console.WriteLine(konec-zacatek);
			}*/

			/*int n = int.Parse(Console.ReadLine());
			string[] cisla = Console.ReadLine().Split();

			int maximalni = 0;
			int aktualni = 1;

			for(int a=0; a+1<cisla.Length; a++)
			{
				if(int.Parse(cisla[a]) *2 >= int.Parse(cisla[a+1]))
				{
					aktualni++;
				}
				else
				{
					if(aktualni > maximalni)
					{
						maximalni = aktualni;

					}
					aktualni = 1;
				}
			}
			if(aktualni > maximalni)
			{
				maximalni = aktualni;

			}
			Console.WriteLine(maximalni); */

		/*
			int pocet = int.Parse(prvni[0]);
			int kolikrat = int.Parse(prvni[1]);
			string retezec = Console.ReadLine();

			string vysledek = "";

			for(int a=1; a<retezec.Length; a++)
			{
				if(retezec[a]== retezec[0])
				{
					bool c = true;
					for( int b = 0; a+b<retezec.Length; b++)
					{
						if(retezec[a+b] != retezec[b])
						{
							c = false;
						}
					}
					if(c)
					{
						int aktualnipocet =1;
						string vocas = retezec.Substring(retezec.Length-a);
						//string
						vysledek = retezec;
						while(aktualnipocet<kolikrat)
						{
							vysledek = vysledek+ vocas;
							aktualnipocet++;
						}
						Console.WriteLine (vysledek);
						return;
					}
				}
			}

			for(int a=0; a<kolikrat; a++)
			{
				vysledek = vysledek+retezec;
			}
			Console.WriteLine (vysledek);
			*/


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1066A {
  class Program {
    static void Main(string[] args) {
      int t = Convert.ToInt32(Console.ReadLine());
      while (t-- != 0) {
        uint[] data = Console.ReadLine().Split(' ').Select(x => Convert.ToUInt32(x)).ToArray();
        uint len = data[0];
        uint v = data[1];
        uint l = data[2];
        uint r = data[3];
        uint tmp1 = (l / v + Convert.ToUInt32(l % v != 0)) * v;
        uint tmp2 = r / v * v;
        uint hidden = (tmp2 - tmp1) / v + 1;
        Console.WriteLine(len / v - hidden);
      }
#if DEBUG
      Console.ReadLine();
#endif
    }
  }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1066A {
  class Program {
    static void Main(string[] args) {
      int t = Convert.ToInt32(Console.ReadLine());
      while (t-- != 0) {
        uint[] data = Console.ReadLine().Split(' ').Select(x => Convert.ToUInt32(x)).ToArray();
        uint len = data[0];
        uint v = data[1];
        uint l = data[2];
        uint r = data[3];
        uint tmp1 = (l / v + Convert.ToUInt32(l % v != 0)) * v;
        uint tmp2 = r / v * v;
        uint hidden = l <= tmp1 && tmp1 <= tmp2 && tmp2 <= r ? (tmp2 - tmp1) / v + 1 : 0;
        Console.WriteLine(len / v - hidden);
      }
#if DEBUG
      Console.ReadLine();
#endif
    }
  }
}


using System;

public class Program
{
	public static void Main()
	{
		long kek;
		int t = Convert.ToInt32(Console.ReadLine());
		for(int i = 0;i<t;i++)
		{
			string[] temp = Console.ReadLine().Split(' ');
			if(Convert.ToInt64(temp[1]) == 1) {Console.WriteLine(Convert.ToInt64(temp[0]) - (Convert.ToInt64(temp[3])-Convert.ToInt64(temp[2])+1)); continue;}
			kek = (Convert.ToInt64(temp[2]) - 1) / Convert.ToInt64(temp[1]);
			kek += (Convert.ToInt64(temp[0]) - Convert.ToInt64(temp[3]) + 1) / Convert.ToInt64(temp[1]);
			Console.WriteLine(kek);
		}
	}
}


using System;

public class Program
{
	public static void Main()
	{
		long kek;
		long gtfobae;
		int t = Convert.ToInt32(Console.ReadLine());
		for(int i = 0;i<t;i++)
		{
			string[] temp = Console.ReadLine().Split(' ');
			long a =Convert.ToInt64(temp[0]);
			long kuk=Convert.ToInt64(temp[1]);
			long st=Convert.ToInt64(temp[2]);
			long ed=Convert.ToInt64(temp[3]);
			if(kuk == 1) {Console.WriteLine(a - (ed-st+1)); continue;}
			gtfobae=kuk;
			kek=0;
			while(gtfobae <= a)
			{
				if(gtfobae<st||gtfobae>ed) kek++;
				gtfobae+=kuk;
			}
			Console.WriteLine(kek);
		}
	}
}


using System;

public class Program
{
	public static void Main()
	{
		long kek;
		int t = Convert.ToInt32(Console.ReadLine());
		for(int i = 0;i<t;i++)
		{
			string[] temp = Console.ReadLine().Split(' ');
			long a =Convert.ToInt64(temp[0]);
			long kuk=Convert.ToInt64(temp[1]);
			long st=Convert.ToInt64(temp[2]);
			long ed=Convert.ToInt64(temp[3]);
			kek = (a/kuk) - (ed/kuk) + ((st-1)/kuk);
			Console.WriteLine(kek);
		}
	}
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			int L = int.Parse(str[0]);
			int V = int.Parse(str[1]);
			int A = int.Parse(str[2]);
			int B = int.Parse(str[3]);
			int a1 = (A-1)/V;
			int a2 = B/V;
			int a3 = L/V;
			int ans = a3 - (a2 - a1);
			Console.WriteLine(ans);
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] y = new string[n];
            bool g=false;
            for (int i = 0; i < n; i++)
            {
                string[] temp = Console.ReadLine().Split(' ');
                Int64 a=int.Parse(temp[0]);
                Int64 b=int.Parse(temp[1]);
                Int64 c=int.Parse(temp[2]);
                Int64 d=int.Parse(temp[3]);
                Int64 q1=a/b;
                Int64 q2=d/b;
                Int64 q3=(c-1)/b;
                Console.WriteLine(q1-q2+q3);
                }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] y = new string[n];
            bool g=false;
            for (int i = 0; i < n; i++)
            {
                string[] temp = Console.ReadLine().Split(' ');
                Int64 a=int.Parse(temp[0]);
                Int64 b=int.Parse(temp[1]);
                Int64 c=int.Parse(temp[2]);
                Int64 d=int.Parse(temp[3]);
                Int64 fonary=(d+1)-c;

                fonary/=b;
                if(fonary<1)
                fonary++;
                Console.WriteLine(a/b-fonary);
                }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Numerics;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;

class Solver
{
    public void Solve(Scanner sc)
    {
        var T = sc.Int;
        while (T-- > 0)
        {
            int L, v, l, r;
            sc.Make(out L, out v, out l, out r);
            WriteLine(L / v - r / v + (l-1) / v);
        }
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static T[] Copy<T>(this T[] A) => Create(A.Length, i => A[i]);
    public static T Unify<T>(this T[] A, Func<T, T, T> f, T init = default(T)) { for (var i = 0; i < A.Length; i++) init = f(init, A[i]);return init; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}

public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _1066a
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            var t = rl<int>();
            for (var i = 0; i < t; i++)
            {
                var len = rn<int>();
                var lamPad = rn<int>();
                var trainStart = rn<int>();
                var trainEnd = rn<int>();

                var lamCount = len / lamPad;

                var start = trainStart / lamPad;
                var end = trainEnd / lamPad;

                lamCount -= end - start;

                if (trainStart % lamPad == 0)
                {
                    lamCount -= 1;
                }

                wl(lamCount);
            }
        }

        private static T rl<T>() { return (T)Convert.ChangeType(Console.ReadLine(), typeof(T)); }
        private static T[] rla<T>(char sep = ' ') { return Console.ReadLine().Split(sep).Select(s => (T)Convert.ChangeType(s, typeof(T))).ToArray(); }
        private static int[] rlai(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), int.Parse); }
        private static long[] rlal(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), long.Parse); }
        private static string[] rlas(char sep = ' ') { return Console.ReadLine().Split(sep); }
        private static List<T> rll<T>(char sep = ' ') { return Console.ReadLine().Split(sep).Select(s => (T)Convert.ChangeType(s, typeof(T))).ToList(); }
        private static T rn<T>(char sep = ' ') { var b = new StringBuilder(); while (true) { var c = (char)Console.In.Read(); if (c == sep || c == '\n') break; b.Append(c); } return (T)Convert.ChangeType(b.ToString(), typeof(T)); }
        private static void wl(object o) { Console.WriteLine(o); }
        private static void wla(int[] arr, string sep = " ") { Console.WriteLine(string.Join(sep, arr)); }
        private static void wla(long[] arr, string sep = " ") { Console.WriteLine(string.Join(sep, arr)); }
        private static void wla(string[] arr, string sep = " ") { Console.WriteLine(string.Join(sep, arr)); }
        private static void w(object o) { Console.Write(o); }
        private static void wn(object o, string sep = " ") { Console.Write(o + sep); }
    }
}


using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace C524
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            for (int i = 0; i < t; i++)
            {
                var Lvlr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
                var lamps = Lvlr[0] / Lvlr[1];
                lamps += 1 / Lvlr[1];
                var lampafterTrain = (Lvlr[3] - Lvlr[2]) / Lvlr[1];
                lampafterTrain += Lvlr[2] % Lvlr[1] == 0 ? 1 : 0;
                if (Lvlr[2] != Lvlr[3])
                    lampafterTrain += Lvlr[3] % Lvlr[1] == 0 ? 1 : 0;
                Console.WriteLine(lamps - lampafterTrain);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace C524
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            for (int i = 0; i < t; i++)
            {
                var Lvlr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
                var slLamps = Lvlr[2] / Lvlr[1];
                var srLamps = Lvlr[3] / Lvlr[1];
                var lamps = Lvlr[0] / Lvlr[1];

                var lampafterTrain = srLamps - slLamps + (Lvlr[2] % Lvlr[1] == 0 ? 1 : 0);

                Console.WriteLine(lamps - lampafterTrain);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace C524
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            for (int i = 0; i < t; i++)
            {
                var Lvlr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
                var lamps = Lvlr[0] / Lvlr[1];
                var lampafterTrain = (Lvlr[3] - Lvlr[2]) / Lvlr[1];
                lampafterTrain += Lvlr[2] % Lvlr[1] == 0 ? 1 : 0;
                Console.WriteLine(lamps - lampafterTrain);

            }
        }

    }
}


using System;
using System.IO;
using System.Text;

namespace Vova_and_Train
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int t = Next();
            for (int i = 0; i < t; i++)
            {
                writer.WriteLine(Solve(args));
            }
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int L = Next();
            int v = Next();
            int l = Next();
            int r = Next();

            int all = L/v;
            int inR = r/v;
            int beforel = (l - 1)/v;

            return all - (inR - beforel);
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
	class Program
	{
		static void Main(string[] args)
		{
			int t = Int32.Parse(Console.ReadLine());
			for (int i = 0; i < t; i++)
			{
				int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				int answer = (a[2] - 1) / a[1] + (a[0] - a[3] + (a[3] % a[1])) / a[1];
				Console.WriteLine(answer);
			}
		}
	}
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		for(;T>0;T--){
			var d = rla();
			L = d[0]; V = d[1]; A = d[2]; B = d[3];

			long lan = L / V;
			long blind = B / V - (A - 1) / V;
			Console.WriteLine(lan - blind);
		}
	}
	long L,V,A,B;
	int T;
	public Sol(){
		T = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string line = Console.ReadLine().Trim();
        int n = int.Parse(line);

        int[] line2;
        int t = 0,L = 0,v = 0,l = 0,r = 0;

        for (int i = 0; i < n; i++)
        {
            t = 0;
            line2 = Array.ConvertAll(Console.ReadLine().Trim().Split(' '),int.Parse);
            L = line2[0];
            v = line2[1];
            l = line2[2];
            r = line2[3];

            //for (int j = v; j <= L; j += v)
            //{
            //    if(j<l || r<j)
            //    {
            //        t++;
            //    }
            //}

            t = L / v - (r/v - (l-1)/v );
            System.Console.WriteLine("{0}",t);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string line = Console.ReadLine().Trim();
        int n = int.Parse(line);

        int[] line2;
        int t = 0,L = 0,v = 0,l = 0,r = 0;

        for (int i = 0; i < n; i++)
        {
            t = 0;
            line2 = Array.ConvertAll(Console.ReadLine().Trim().Split(' '),int.Parse);
            L = line2[0];
            v = line2[1];
            l = line2[2];
            r = line2[3];

            //for (int j = v; j <= L; j += v)
            //{
            //    if(j<l || r<j)
            //    {
            //        t++;
            //    }
            //}

            t = L / v - ((r -l)/ v );
            if (r % v == 0 && l % v == 0)
            { t--; }
            System.Console.WriteLine("{0}",t);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string line = Console.ReadLine().Trim();
        int n = int.Parse(line);

        int[] line2;
        int t = 0,L = 0,v = 0,l = 0,r = 0;

        for (int i = 0; i < n; i++)
        {
            t = 0;
            line2 = Array.ConvertAll(Console.ReadLine().Trim().Split(' '),int.Parse);
            L = line2[0];
            v = line2[1];
            l = line2[2];
            r = line2[3];

            for (int j = v; j <= L; j += v)
            {
                if(j<l || r<j)
                {
                    t++;
                }
            }
            System.Console.WriteLine("{0}",t);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace W0lf
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for(long i = 0; i < n; i++)
            {
                long f = 0;
                string[] s = Console.ReadLine().Split(' ');
                long L = long.Parse(s[0]);
                long v = long.Parse(s[1]);
                long x = long.Parse(s[2]);
                long y = long.Parse(s[3]);
                if(x == 1 && y == L) Console.WriteLine(f);
                else
                {
                    f = L / v;
                    for(long j = 1; j <= f; j++)
                    {
                        if(v * j >= x && v * j <= y) f--;
                    }
                    Console.WriteLine(f);
                }
            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace W0lf
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for(int i = 0; i < n; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                int L = int.Parse(str[0]);
                int v = int.Parse(str[1]);
                int x = int.Parse(str[2]);
                int y = int.Parse(str[3]);
                Console.WriteLine((L / v) - (y / v - ((x - 1)/ v)));
            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace W0lf
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for(long i = 0; i < n; i++)
            {
                long f = 0;
                string[] s = Console.ReadLine().Split(' ');
                long L = long.Parse(s[0]);
                long v = long.Parse(s[1]);
                long x = long.Parse(s[2]);
                long y = long.Parse(s[3]);
                if(x != 1 && y != L)
                {
                    f = L / v;
                    for(long j = 1; j <= f; j++)
                    {
                        if(v * j >= x && v * j <= y) f--;
                    }
                }
                Console.WriteLine(f);
            }
            Console.ReadLine();
        }
    }
}


/*
csc -debug A.cs && mono --debug A.exe <<< "4
10 2 3 7
100 51 51 51
1234 1 100 199
1000000000 1 1 1000000000"
*/

using System;
using System.Collections.Generic;
using System.Linq;

public class HelloWorld {
    static public void Main () {
        SolveCodeForces();
    }

    public static void SolveCodeForces() {
        var t = long.Parse(Console.ReadLine());
        for (var ti = 0; ti < t; ti++) {
            var arr = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var L = arr[0];
            var v = arr[1];
            var l = arr[2];
            var r = arr[3];
            var a = (l-1) / v;
            var b = r / v;
            var c = L / v;
            System.Console.WriteLine(c - b + a);
        }
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}


using System;

namespace round515
{
  class MainClass
  {
    public static void Main(string[] args)
    {
      var t = int.Parse(Console.ReadLine());
      for (int i = 0; i < t; ++i)
      {
        var line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var L = line[0];
        var v = line[1];
        var l = line[2];
        var r = line[3];

        var a1 = (1 + v - 1) / v * v;
        var a2 = L / v * v;
        var s1 = (l + v - 1) / v * v;
        var s2 = r / v * v;

        int answer = ((a2 - a1) / v + 1) - ((s2 - s1) / v + 1);
        Console.WriteLine(answer);
      }
    }
  }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp21
{
    class Program
    {
        static void Main(string[] args)
        {
            int casos = int.Parse(Console.ReadLine());
            while (casos > 0)
            {
                string[] arr = Console.ReadLine().Split(' ');
                long[] valores = new long [4];
                for (int i = 0; i < 4; i++)
                    valores[i] = int.Parse(arr[i]);
                long L = valores[0];
                long v = valores[1];
                long l = valores[2];
                long r = valores[3];
                long resp = 0;
                resp += (L / v) - ((r/v) - ((l-1)/v) );
                Console.WriteLine(resp);
                casos--;
            }
        }
    }
}


using System;
namespace CodeForces
{
    public class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int t = int.Parse(line);
            while (t > 0) {
                line = Console.ReadLine();
                string [] vars = line.Split(' ');
                int L = int.Parse(vars[0]);
                int v = int.Parse(vars[1]);
                int l = int.Parse(vars[2]);
                int r = int.Parse(vars[3]);

                int TotalLights = L / v;
                int CoveredLights = r / v - (l - 1) / v;

                int sol = TotalLights - CoveredLights;
                Console.WriteLine(sol);

                t--;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    public void Solve()
    {
        for (int tt = ReadInt(); tt > 0; tt--)
        {
            int d = ReadInt();
            int p = ReadInt();
            int l = ReadInt();
            int r = ReadInt();
            Write(d / p - r / p + (l - 1) / p);
        }
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("stations.in");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace _1066A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line1 = Console.ReadLine();
            if (new Regex(@"^\d+$").IsMatch(line1))
            {
                int a = int.Parse(line1);
                string[] lines = new string[a];
                for(int i = 0; i < a; i++)
                {
                    lines[i] = Console.ReadLine();
                }

                for (int i = 0; i < a; i++)
                {
                    if (new Regex(@"^\d+\s+\d+\s+\d+\s+\d+$").IsMatch(lines[i]))
                    {
                        string[] tokens = lines[i].Split();
                        long n = long.Parse(tokens[0]);
                        long v = long.Parse(tokens[1]);
                        long l = long.Parse(tokens[2]);
                        long r = long.Parse(tokens[3]);
                        long res = n / v - r / v + l / v;
                        if (l % v == 0)
                        {
                            res--;
                        }
                        Console.WriteLine(res);

                    }
                }

            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace _1066A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line1 = Console.ReadLine();
            if (new Regex(@"^\d+$").IsMatch(line1))
            {
                int a = int.Parse(line1);
                string[] lines = new string[a];
                for(int i = 0; i < a; i++)
                {
                    lines[i] = Console.ReadLine();
                }

                for (int i = 0; i < a; i++)
                {
                    if (new Regex(@"^\d+\s+\d+\s+\d+\s+\d+$").IsMatch(lines[i]))
                    {
                        string[] tokens = lines[i].Split();
                        long n = long.Parse(tokens[0]);
                        long v = long.Parse(tokens[1]);
                        long l = long.Parse(tokens[2]);
                        long r = long.Parse(tokens[3]);
                        long res = n / v - (r - l) / v;
                        if ( ((r - l) <= v) && ((r / v) > (l / v)) )
                        {
                            res--;
                        }
                        if (((l % v) == 0) && ((r % v) == 0))
                            res--;
                        Console.WriteLine(res);

                    }
                }

            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace _1066A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line1 = Console.ReadLine();
            if (new Regex(@"^\d+$").IsMatch(line1))
            {
                int a = int.Parse(line1);
                string[] lines = new string[a];
                for(int i = 0; i < a; i++)
                {
                    lines[i] = Console.ReadLine();
                }

                for (int i = 0; i < a; i++)
                {
                    if (new Regex(@"^\d+\s+\d+\s+\d+\s+\d+$").IsMatch(lines[i]))
                    {
                        string[] tokens = lines[i].Split();
                        long n = long.Parse(tokens[0]);
                        long v = long.Parse(tokens[1]);
                        long l = long.Parse(tokens[2]);
                        long r = long.Parse(tokens[3]);
                        long res = n / v - r / v + l / v;
                        if (l % v == 0 || r % v == 0)
                        {
                            res--;
                        }
                        Console.WriteLine(res);

                    }
                }

            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace _1066A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line1 = Console.ReadLine();
            if (new Regex(@"^\d+$").IsMatch(line1))
            {
                int a = int.Parse(line1);
                string[] lines = new string[a];
                for(int i = 0; i < a; i++)
                {
                    lines[i] = Console.ReadLine();
                }

                for (int i = 0; i < a; i++)
                {
                    if (new Regex(@"^\d+\s+\d+\s+\d+\s+\d+$").IsMatch(lines[i]))
                    {
                        string[] tokens = lines[i].Split();
                        long n = long.Parse(tokens[0]);
                        long v = long.Parse(tokens[1]);
                        long l = long.Parse(tokens[2]);
                        long r = long.Parse(tokens[3]);
                        long res = n / v - (r - l) / v;
                        if (((l % v) == 0) && ((r % v) == 0))
                            res--;
                        Console.WriteLine(res);

                    }
                }

            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var lines = int.Parse(Console.ReadLine());
            for (int i = 0; i < lines; i++)
            {
                var input = Console.ReadLine();
                var chunks = input.Split(' ').Select(decimal.Parse).ToList();
                var total = Math.Floor(chunks[0] / chunks[1]);
                var hasil = hitung(chunks[1], chunks[2], chunks[3]);
                Console.WriteLine(total - hasil);
            }
        }

        private static decimal hitung(decimal kelipatan, decimal start, decimal end)
        {
            if (start == end)
            {
                return kelipatan == start ? 1 : 0;
            }

            var result = Math.Floor(end - start + 1) / kelipatan;
            return result;
        }
    }
}


using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var lines = int.Parse(Console.ReadLine());
            for (int i = 0; i < lines; i++)
            {
                var input = Console.ReadLine();
                var chunks = input.Split(' ').Select(decimal.Parse).ToList();
                var total = chunks[0] / chunks[1];
                var hasil = hitung(chunks[1], chunks[2], chunks[3]);
                Console.WriteLine(total-hasil);
            }

        }

        private static decimal hitung(decimal kelipatan, decimal start, decimal end)
        {
            return Math.Floor((end - start + 1) / kelipatan);
        }
    }
}


using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //var aa = parse("989468985 296612298 509835600 762415605");
            //var bb = parse("100 51 51 51");
            var lines = int.Parse(Console.ReadLine());
            for (int i = 0; i < lines; i++)
            {
                var input = Console.ReadLine();
                var result = parse(input);
                Console.WriteLine(result);
            }
        }

        private static decimal parse(string value)
        {
            var chunks = value.Split(' ').Select(decimal.Parse).ToList();
            var result = getResult(chunks[0], chunks[1], chunks[2], chunks[3]);
            return result;
        }

        private static decimal getResult(decimal distance, decimal kelipatan, decimal start, decimal end)
        {
            var total = Math.Floor(distance / kelipatan);
            var hasil = hitung(kelipatan, start, end);
            return total - hasil;
        }

        private static decimal hitung(decimal kelipatan, decimal start, decimal end)
        {
            var awal = Math.Floor(start / kelipatan) * kelipatan;
            var train = end - awal + 1;
            var result = Math.Floor(train / kelipatan);
            return result;
        }
    }
}


using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //var aa = parse("10 2 3 7",3);
            //var bb = parse("100 51 51 51", 0);
            //var cc = parse("1234 1 100 199", 1134);
            //var dd = parse("1000000000 1 1 1000000000", 0);
            //var ee = parse("989468985 296612298 509835600 762415605");

            var lines = int.Parse(Console.ReadLine());
            for (int i = 0; i < lines; i++)
            {
                var input = Console.ReadLine();
                var result = parse(input);
                Console.WriteLine(result);
            }
        }

        private static decimal parse(string value, decimal? compare = null)
        {
            var chunks = value.Split(' ').Select(decimal.Parse).ToList();
            var result = getResult(chunks[0], chunks[1], chunks[2], chunks[3]);

            if (compare != null && result!=compare)
                throw new Exception("Expected:" + compare + ", Answer:" + result);

            return result;
        }

        private static decimal getResult(decimal distance, decimal kelipatan, decimal start, decimal end)
        {
            var total = Math.Floor(distance / kelipatan);
            var hasil = hitung(kelipatan, start, end);
            return total - hasil;
        }

        private static decimal hitung(decimal kelipatan, decimal start, decimal end)
        {
            var awal = Math.Floor(start / kelipatan) * kelipatan;
            if (awal < start) awal += kelipatan;
            var akhir = Math.Floor(end / kelipatan) * kelipatan;
            var train = akhir - awal;
            var result = Math.Floor(train / kelipatan) + 1;
            return result;
        }
    }
}


using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var lines = int.Parse(Console.ReadLine());
            for (int i = 0; i < lines; i++)
            {
                var input = Console.ReadLine();
                var chunks = input.Split(' ').Select(decimal.Parse).ToList();
                var total = chunks[0] / chunks[1];
                var hasil = hitung(chunks[1], chunks[2], chunks[3]);
                Console.WriteLine(total - hasil);
            }
        }

        private static decimal hitung(decimal kelipatan, decimal start, decimal end)
        {
            var current = Math.Floor(start / kelipatan) * kelipatan;
            var count = 0;
            while (current <= end)
            {
                count++;
                current += kelipatan;
            }

            return count;
        }
    }
}


using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var lines = int.Parse(Console.ReadLine());
            for (int i = 0; i < lines; i++)
            {
                var input = Console.ReadLine();
                var chunks = input.Split(' ').Select(decimal.Parse).ToList();
                var total = Math.Floor(chunks[0] / chunks[1]);
                var hasil = hitung(chunks[1], chunks[2], chunks[3]);
                Console.WriteLine(total - hasil);
            }
        }

        private static decimal hitung(decimal kelipatan, decimal start, decimal end)
        {
            if (start == end)
            {
                return kelipatan == start ? 1 : 0;
            }

            var result = Math.Floor((end - start + 1) / kelipatan);
            return result;
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int kazu = int.Parse(input[0]);
        int kaisu = int.Parse(input[1]) -1;*/
//        string[] ttemp = ReadLine().Split(' ');
//        int[] takasa = new int[kazu];
        int kazu = int.Parse(ReadLine());
        for(int i=0;i<kazu;i++){
            string[] asdf = ReadLine().Split(' ');
            int saidai = int.Parse(asdf[0]);
            int kankaku = int.Parse(asdf[1]);
            int syou = int.Parse(asdf[2]);
            int dai = int.Parse(asdf[3]);

            int all = saidai / kankaku;
            int syoutemp = syou/kankaku;
            int daitemp = dai/kankaku;
            int hiku = daitemp - syoutemp;
            if(syou%kankaku == 0){
                hiku++;
            }
            WriteLine(all-hiku);
        }
    }
}


using System;
using System.IO;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

class Program
{
    class T
    {
        public int X;
        public int Y;

        public T(int x, int y)
        {
            X = x;
            Y = y;
        }
    }
    //////////////////////////////////////////////////

    //////////////////////////////////////////////////
    void Solution()
    {
        var t = ri;
        for (int i = 0; i < t; i++)
        {
            var L = ri;
            var v = ri;
            var l = ri;
            var r = ri;
            wln((L / v) - (r / v) + ((l - 1) / v));
        }

    }
    //////////////////////////////////////////////////

    struct P : IComparable<P>
    {
        public long X;
        public long Y;

        public P(long x, long y)
        {
            X = x;
            Y = y;
        }

        public int CompareTo(P other) => X != other.X ? X.CompareTo(other.X) : Y.CompareTo(other.Y);
        public static int Comparison(P p1, P p2) => p1.CompareTo(p2);

        public static bool operator ==(P p1, P p2) => (p1.X == p2.X) && (p1.Y == p2.Y);
        public static bool operator !=(P p1, P p2) => (p1.X != p2.X) || (p1.Y != p2.Y);

        public static P operator +(P p1, P p2) => new P(p1.X + p2.X, p1.Y + p2.Y);
        public static P operator -(P p1, P p2) => new P(p1.X - p2.X, p1.Y - p2.Y);
    }

    void swap<T>(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }
    long gcd(long a, long b) => (b != 0) ? gcd(b, a % b) : a;
    long lcm(long a, long b) => a / gcd(a, b) * b;

    long rast2(long x1, long y1, long x2, long y2) => (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
    long rast2(P p1, P p2) => (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);
    long ccw(P p1, P p2, P p3) => p1.X * p2.Y + p1.Y * p3.X + p2.X * p3.Y - p2.Y * p3.X - p3.Y * p1.X - p1.Y * p2.X;

    StringBuilder _sb = new StringBuilder();
    void wln() { _sb.AppendLine(); }
    void wln<T>(T o) { _sb.AppendLine(o.ToString()); }
    void wsp<T>(T o) { _sb.Append(o).Append(" "); }
    void wrt<T>(T o) { _sb.Append(o); }
    void wln(double o) { _sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }
    void wsp(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, "{0:F12} ", o)); }
    void wrt(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }

    List<P> rpa(int n)
    {
        var res = new List<P>(n);
        for (int i = 0; i < n; i++)
            res.Add(new P(rl, rl));
        return res;
    }

    int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    long rl
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    double rd
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';
            if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;
        }
    }
    string rs
    {
        get
        {
            _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;
            var tmp = _str.IndexOf(' ', _ind);
            if (tmp == -1) { var res = _str.Substring(_ind); _count = 0; _ind = 0; return res; }
            var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;
        }
    }

    List<int> ria(int n)
    {
        var res = new int[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res.ToList();
    }
    List<long> rla(int n)
    {
        var res = new long[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res.ToList();
    }
    List<double> rda(int n)
    {
        var res = new double[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';
                if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }
                res[k++] = (double)p / q * sign;
            }
        }
        _count = 0; _ind = 0; return res.ToList();
    }
    List<string> rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res.ToList(); }
    string _str = null; int _count = 0; int _ind = 0;
    void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }
    static void Main(string[] args) { new Program().Main(); }
    void Main()
    {
        //Console.SetIn(new StreamReader("input.txt")); Console.SetOut(new StreamWriter("output.txt"));
        Solution();
        Console.Write(_sb);
        //Console.In.Close(); Console.Out.Close();
    }
}


using System;
using System.Text;

class Program
{
    static void Solution()
    {
        var t = ri;
        for (int i = 0; i < t; i++)
        {
            var L = ri;
            var v = ri;
            var l = ri;
            var r = ri;
            wln((L / v) - (r / v) + ((l - 1) / v));
        }
    }

    static StringBuilder _sb = new StringBuilder();

    static void wln<T>(T o) { _sb.AppendLine(o.ToString()); }

    static int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }

    static string _str = null;
    static int _count = 0;
    static int _ind = 0;

    static void _read()
    {
        if (_ind == _count)
        {
            _str = Console.ReadLine();
            _count = _str.Length; _ind = 0;
        }
    }

    static void Main(string[] args)
    {
        Solution();
        Console.Write(_sb);
    }

}


using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("T = ");
            var t = int.Parse(Console.ReadLine());
            var m = new int[t, 4];
            for (int i = 0; i < t; i++)
            {
                for(int j = 0; j < 4; j++)
                {
                    m[i,j] = Convert.ToInt32(Console.ReadLine());
                }
            }

            for(int i = 0; i < t; i++)
            {
                var result = 0;
                var lanterns = m[i, 0] / m[i, 1];
                for(int j = 1; j <= lanterns; j++)
                {
                    if(j* m[i, 1]< m[i, 2] || j * m[i, 1] > m[i, 3])
                    {
                        result++;

                    }
                }
                Console.WriteLine(result);

            }

            //Console.ReadLine();
        }
    }
}


using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = int.Parse(Console.ReadLine());
            var m = new int[t][];
            for (int i = 0; i < t; i++)
            {
                m[i]= Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            }

            for(int i = 0; i < t; i++)
            {
                var result = 0;
                var lanterns = m[i][0] / m[i][1];
                for(int j = 1; j <= lanterns; j++)
                {
                    if(j* m[i][1]< m[i][2] || j * m[i][1] > m[i][3])
                    {
                        result++;
                    }
                }
                Console.WriteLine(result);
            }

        }
    }
}


using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = int.Parse(Console.ReadLine());
            var m = new int[t][];
            for (int i = 0; i < t; i++)
            {
                m[i]= Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            }

            for(int i = 0; i < t; i++)
            {
                var result = 0;
                var lanterns = m[i][0] / m[i][1];
                var l = (m[i][2] % m[i][1] != 0) ? m[i][2] / m[i][1] : (m[i][2] / m[i][1]) - 1;
                var r = (m[i][3] % m[i][1] != 0) ? m[i][3] / m[i][1] : (m[i][3] / m[i][1]) + 1;
                result = lanterns - r + l;
                Console.WriteLine(result);
            }

        }
    }
}


using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = int.Parse(Console.ReadLine());
            var m = new int[t][];
            for (int i = 0; i < t; i++)
            {
                m[i]= Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            }

            for(int i = 0; i < t; i++)
            {
                var result = 0;
                var lanterns = m[i][0] / m[i][1];
                var l = (m[i][2] % m[i][1] != 0) ? m[i][2] / m[i][1] : (m[i][2] / m[i][1]) - 1;
                var r = m[i][3] / m[i][1]; //(m[i][3] % m[i][1] != 0) ? m[i][3] / m[i][1] : (m[i][3] / m[i][1]) + 1;
                result = lanterns - r + l;
                Console.WriteLine(result);
            }

        }
    }
}


using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = int.Parse(Console.ReadLine());
            var m = new int[t, 4];
            for (int i = 0; i < t; i++)
            {
                for(int j = 0; j < 4; j++)
                {
                    m[i,j] = Convert.ToInt32(Console.ReadLine());
                }
            }

            for(int i = 0; i < t; i++)
            {
                var result = 0;
                var lanterns = m[i, 0] / m[i, 1];
                for(int j = 1; j <= lanterns; j++)
                {
                    if(j* m[i, 1]< m[i, 2] || j * m[i, 1] > m[i, 3])
                    {
                        result++;

                    }
                }
                Console.WriteLine(result);

            }

            //Console.ReadLine();
        }
    }
}


use std::io;

macro_rules! readln {
    () => {{
        use std::io;
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim().to_string()
    }};
    ( $t:ty ) => {{
        let input = readln!();
        input.parse::<$t>().unwrap()
    }};
    ( $( $t:ty ),+ ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        (
            $(
                input.next().unwrap().parse::<$t>().unwrap(),
            )+
        )
    }}
}

fn main() {
    let tests = readln!(i16);
    for _ in 0..tests {
        let (dest, lamps, train_left, train_right) = readln!(i32, i32, i32, i32);

        println!("{}", dest / lamps - train_right / lamps + (train_left - 1) / lamps);
    }
}


#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_labels)]

use std::char::*;
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;

macro_rules! debug {($($a:expr),*) => {eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::f64;

fn min<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { a }
    else { b }
}

fn max<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { b }
    else { a }
}

const MAX:usize = 30;
const INF:i64 = std::i64::MAX;
const MOD:i64 = 1e9 as i64 + 7;

fn main() {
    let t:usize = read();

    'outer: for _ in 0..t {
        let a:i64 = read();
        let v:i64 = read();
        let l:i64 = read();
        let r:i64 = read();

        println!("{}", a/v - r/v + (l-1)/v);
    }
}

/*

*/


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input!{
        t: usize,
        lvlr: [(i64, i64, i64, i64); t],
    }
    for (ll, v, l, r) in lvlr {
        let ans = ll / v + (l - 1) / v - r / v;
        puts!("{}\n", ans);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


package main

import (
  "fmt"
)

var t int
var len, v, l, r int

func divNum(x, v int) int {
  return x / v
}

func main() {
  fmt.Scanf("%d\n", &t);

  for i := 0; i < t; i++ {
    fmt.Scanf("%d %d %d %d\n", &len, &v, &l, &r)
    fmt.Printf("%d\n", divNum(len, v) - divNum(r, v) + divNum(l - 1, v))
  }
}


package main

import (
  "fmt"
  "bufio"
  "os"
)

var t int
var len, v, l, r int

func divNum(x, v int) int {
  return x / v
}

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  fmt.Fscanf(reader, "%d\n", &t);

  for i := 0; i < t; i++ {
    fmt.Fscanf(reader, "%d %d %d %d\n", &len, &v, &l, &r)
    fmt.Fprintf(writer, "%d\n", divNum(len, v) - divNum(r, v) + divNum(l - 1, v))
  }
}


package main

import "fmt"

func main() {
	var(
		t int64
	)
	var L, v, l, r int64

	fmt.Scan(&t)
	for i := int64(0); i < t; i ++ {
		fmt.Scan(&L, &v, &l, &r)
		fmt.Printf("%d\n",L / v - r / v + (l-1) / v);
	}

}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin);
	writer := bufio.NewWriter(os.Stdout);

	var(
		t int64
	)
	var L, v, l, r int64

	fmt.Fscan(reader, &t)
	for i := int64(0); i < t; i ++ {
		fmt.Fscan(reader, &L, &v, &l, &r)
		fmt.Fprintf(writer,"%d\n",L / v - r / v + (l-1) / v);
	}

}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin);
	writer := bufio.NewWriter(os.Stdout);

	var(
		t int64
	)
	var L, v, l, r int64

	fmt.Fscan(reader, &t)
	for i := int64(0); i < t; i ++ {
		fmt.Fscan(reader, &L, &v, &l, &r)
		fmt.Fprintf(writer,"%d\n",L / v - r / v + (l-1) / v);
	}
	writer.Flush();
}


<?php
    $num =(int)fgets(STDIN);
    $res=[];
    while ($num-->0){
        $str=fgets(STDIN);
        $str = explode(' ',$str);
        $ll=(int)$str[0];
        $v=(int)$str[1];
        $l=(int)$str[2];
        $r=(int)$str[3];

        //первый столб после поезда
        if ($v>$r) {
            $count = floor($ll/$v);
            $res[]=$count;
            continue;
        }

        //первый столб до поезда
        if ($v<=$l) {
            $a = floor($l/$v);
            if (!($l%$v)) {
                $a--;
            }
            $b = floor($r/$v);
            $c = floor($ll/$v);
            $count = $c-($b-$a);
            $res[]=$count;
            continue;
        }

        //первый фонарь между поездом
        if ($l<$v && $v<=$r) {
            $b = floor($r/$v);
            $c = floor($ll/$v);
            $count = $c-$b;
            $res[]=$count;
            continue;
        }

        //ll - пункт назначения
        //v - позиция фонаря
        //l - начало длины поезда
        //r - конец длины поезда

        //686817107 73138233 67053564 180837627
        //7

        //868494849 135243336 281738625 468972539
        //5

        //100 51 51 51
        //0

        //10 2 3 7
        //3

        //1234 1 100 199
        //1134

        //99 200
    }
    /*
echo '______
';
    */
    foreach ($res as $r) {
        echo $r.'
';
    }

?>


<?php
    $num =(int)fgets(STDIN);
    $res=[];
    while ($num-->0){
        $str=fgets(STDIN);
        $str = explode(' ',$str);
        $ll=(int)$str[0];
        $v=(int)$str[1];
        $l=(int)$str[2];
        $r=(int)$str[3];

        if ($v>$r) {
            $count = floor($ll/$v);
            $res[]=$count;
            continue;
        }

        if ($v<$l && $r<$ll) {
            $a = floor($l/$v);
            if (!($l%$v)) {
                $a--;
            }
            $b = floor($r/$v);
            $c = floor($ll/$v);
            $count = $c-($b-$a);
            $res[]=$count;
            continue;
        }

        //первый фонарь между поездом
        if ($l<$v && $v<$r) {
            $b = floor($r/$v);
            $c = floor($ll/$v);
            $count = $c-$b;
            $res[]=$count;
            continue;
        }

        if ($v > $r) {
            $c = floor($ll/$v);
            $count = $c;
            $res[]=$count;
            continue;
        }

        $i = $v;
        $count = 0;

        if ($i<$l) {
            $c = floor($l / $v);
            if (!($l%$v)) {
                $c--;
            }
/*
            echo $c.' (1)
';
*/
            $count+=$c;
        }

        $k2 = 0;
        if ($r>$v){
            $k2 = floor($r / $v);
        }

        $k3 = ($k2+1) *$v;
        if ($ll>$k3 && !(($ll-$k3)%$v)) {
            $count+=1;
/*
            echo '1 (2)
';
*/
        }

        if ($r<$ll) {
            $k = $ll - $k3;
            $c = floor($k / $v);
            if ($c<0){
                $c=0;
            }
            $count += $c;
/*
            echo $c . ' (3)
';
*/

        }

/*

        while ($i<=$ll) {
            if ($i<$l || $i>$r) {
                $count++;
                echo $i.'
';
            }
            $i+=$v;

        }
*/
        //echo $count;
        $res[]=$count;

        //ll - пункт назначения
        //v - позиция фонаря
        //l - начало длины поезда
        //r - конец длины поезда

        //686817107 73138233 67053564 180837627
        //7

        //868494849 135243336 281738625 468972539
        //5

        //100 51 51 51
        //0

        //10 2 3 7
        //3

        //1234 1 100 199
        //1134

        //99 200
    }
    /*
echo '______
';
    */
    foreach ($res as $r) {
        echo $r.'
';
    }

?>


from math import ceil, floor

T = input()

for t in xrange(T):
    d, v, l, r = map(int, raw_input().split(" "))

    ll = int(ceil(float(l)/v))
    rr = int(floor(float(r)/v))

    if rr < ll:
        now = 0
    else:
        now = rr - ll + 1

    print int(floor(float(d) / v)) - now


import sys
sys.stdin.readline()
for e in sys.stdin;_,v,l,r=map(int,e.split());print(_//v-r//v+(l-1)/.v)


import sys
sys.stdin.readline()
for e in sys.stdin:_,v,l,r=map(int,e.split());print(_//v-r//v+(l-1)/.v)


import sys
sys.stdin.readline()
for e in sys.stdin:_,v,l,r=map(int,e.split());print(_//v-r//v+(l-1)//v)


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


#!/usr/bin/env pypy
# Author : prayushd
# Language : Python

from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from itertools import imap as map, izip as zip
from __builtin__ import xrange as range
from math import ceil
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
import sys
import os
import re
inf = float('inf')
mod = int(1e9) + 7
mod_ = 998244353

'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''

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

BUFSIZE = 8192
class FastI(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = StringIO()
		self.newlines = 0

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

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count("\n") + (not b)
			ptr = self._buffer.tell()
			self._buffer.seek(0, 2), self._buffer.write(
				b), self._buffer.seek(ptr)
		self.newlines -= 1
		return self._buffer.readline()
class FastO(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = __pypy__.builders.StringBuilder()
		self.write = lambda s: self._buffer.append(s)

	def flush(self):
		os.write(self._fd, self._buffer.build())
		self._buffer = __pypy__.builders.StringBuilder()
def print(*args, **kwargs):
	sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop("end", "\n"))
	if kwargs.pop("flush", False):
		file.flush()
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
	def bootstrap(cont):
		call, arg = cont.switch()
		while True:
			call, arg = cont.switch(to=continulet(
				lambda _, f, args: f(*args), call, arg))
	cont = continulet(bootstrap)
	cont.switch()
	main()


"""
What I cannot create, I do not understand.

https://github.com/Cheran-Senthil/PyRival
Copyright (c) 2018 Cheran Senthilkumar
"""
# IMPORTS---------------------------------------------------------------------#
from __future__ import division, print_function

import itertools
import sys
from atexit import register
from io import BytesIO

# import cmath
# import math
# import operator as op
# import random
# from bisect import bisect, bisect_left
# from collections import Counter, defaultdict, deque
# from copy import deepcopy
# from cPickle import dumps
# from decimal import Decimal, getcontext
# from difflib import SequenceMatcher
# from fractions import Fraction, gcd
# from heapq import heappop, heappush
# from Queue import PriorityQueue, Queue

# PYTHON3---------------------------------------------------------------------#
class dict(dict):
    def items(self):
        return dict.iteritems(self)

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

    def values(self):
        return dict.itervalues(self)

filter = itertools.ifilter
map = itertools.imap
zip = itertools.izip

input = raw_input
range = xrange

# FASTIO----------------------------------------------------------------------#
# sys.stdout = BytesIO()
# register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
# sys.stdin = BytesIO(sys.stdin.read())

# input = lambda: sys.stdin.readline().rstrip()
# print = lambda *args: sys.stdout.write(' '.join(str(x) for x in args) + '\n')
# flush = sys.stdout.flush

# SETTINGS--------------------------------------------------------------------#
# getcontext().prec = 100
# sys.setrecursionlimit(100000)

# CONSTANTS-------------------------------------------------------------------#
MOD = 1000000007
INF = float('+inf')

ASCII_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz'
ASCII_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

# MAIN------------------------------------------------------------------------#
def main():
    t = int(input())
    for _ in range(t):
        L, v, l, r = map(int, input().split(' '))
        new_l = (l % v)
        if new_l == 0:
            new_l = v
        new_r = r - l + new_l
        print((L // v) - (new_r // v))

if __name__ == '__main__':
    main()


t = int(raw_input())

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


t=input()
from  math import *
for _ in range(0,t):
    cap_l,v,l,r=map(int,raw_input().split())
    v1=(l-1)/v
    v2=r/v
    v3=cap_l/v
    print v3-v2+v1
    #v2=
   # print v1+v2


"""
What I cannot create, I do not understand.

https://github.com/Cheran-Senthil/PyRival
Copyright (c) 2018 Cheran Senthilkumar
"""
# IMPORTS---------------------------------------------------------------------#
from __future__ import division, print_function

import itertools
import sys
from atexit import register
from io import BytesIO

# import cmath
import math
# import operator as op
# import random
# from bisect import bisect, bisect_left
# from collections import Counter, defaultdict, deque
# from copy import deepcopy
# from cPickle import dumps
# from decimal import Decimal, getcontext
# from difflib import SequenceMatcher
# from fractions import Fraction, gcd
# from heapq import heappop, heappush
# from Queue import PriorityQueue, Queue

# PYTHON3---------------------------------------------------------------------#
class dict(dict):
    def items(self):
        return dict.iteritems(self)

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

    def values(self):
        return dict.itervalues(self)

filter = itertools.ifilter
map = itertools.imap
zip = itertools.izip

input = raw_input
range = xrange

# FASTIO----------------------------------------------------------------------#
# sys.stdout = BytesIO()
# register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
# sys.stdin = BytesIO(sys.stdin.read())

# input = lambda: sys.stdin.readline().rstrip()
# print = lambda *args: sys.stdout.write(' '.join(str(x) for x in args) + '\n')
# flush = sys.stdout.flush

# SETTINGS--------------------------------------------------------------------#
# getcontext().prec = 100
# sys.setrecursionlimit(100000)

# CONSTANTS-------------------------------------------------------------------#
MOD = 1000000007
INF = float('+inf')

ASCII_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz'
ASCII_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

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

if __name__ == '__main__':
    main()


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


for t in xrange(input()):
	a,b,c,d = map(int,raw_input().split())
	ans = a/b
	x = d/b - (c-1)/b
	print ans-x


t = input()
out = []
for q in range(t):
    a,b,c,d = map(int,raw_input().split())
    b1 = a//b
    b2 = (c//b)
    if(c%b == 0):
        b2-=1
    b3 = (d//b)
    out.append(str(b1-(b3-b2)))

print("\n".join(out))


from sys import stdin,stdout
for _ in xrange(int(stdin.readline())):
    L,v,l,r = map(int,stdin.readline().split())
    ans = (L/v) - ( (r/v) - ((l-1)/v) )
    stdout.write("%d\n"%ans)


t = int(raw_input())
while t:
	t-=1
	dest, v,l,r = map(int, raw_input().split())
	diff = (r-l)
	if(l%v==0):
		print dest/v - (diff/v + 1)
	else:
		print dest/v - diff/v


t = int(raw_input())
while t:
	t-=1
	dest, v,l,r = map(int, raw_input().split())
	diff = min(dest,r)+(v-min(dest,r)%v) - (l+(v-l%v))
	if(min(dest,r)%v==0):
		print dest/v - (diff/v + 1)
	else:
		print dest/v - diff/v


t = int(raw_input())
while t:
	t-=1
	dest, v,l,r = map(int, raw_input().split())
	diff = r+(v-(r%v)) - (l+(v-(l%v)))
	if(l%v==0):
		print dest/v - (diff/v + 1)
	else:
		print dest/v - diff/v


from sys import stdin, stdout

t = input()
inp = stdin.readlines()
out = []

for line in inp:
    L, v, l, r = map(int, line.strip().split())
    lan = L // v
    lo = (l + v - 1) // v
    hi = r // v
    cov = hi - lo + 1
    ans = lan - cov
    out.append(str(ans))

stdout.write("\n".join(out))


import sys

def calc_fonari(L, v, l, r):
    left_part = (l - 1) / v
    with_train = r / v
    total_part = L / v
    total = left_part + (total_part - with_train)
    return total

if __name__ == "__main__":
    i = int(sys.stdin.readline())
    for line in sys.stdin:
        L, v, l, r = [int(i) for i in line.strip().split()]
        print calc_fonari(L, v, l, r)


#include<bits/stdc++.h>  //假如其中的项全部是前面的便可以构造
#define mod 1000000007
#define ll long long
using namespace std;
int n;
int cnt[10];
struct mx
{
	ll m[105][105];
	mx(){memset(m,0,sizeof(m));}
	mx operator *(const mx &b) const
	{
		mx tmp;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(m[i][j]!=0)
				{
					for(int k=0;k<n;k++)
					{
						tmp.m[i][k]=(tmp.m[i][k]+m[i][j]*b.m[j][k])%mod;
					}
				}
			}
		}
		return tmp;
	}
}base,ans;

void poww(int n)
{
	for(int i=0;i<n;i++)
		ans.m[i][i]=1;
	while(n)
	{
		if(n&1)
			ans=ans*base;
		n=(n>>1);
		base=base*base;
	}
}
int main()
{
	int b,k,x;cin>>n>>b>>k>>x;
	for(int i=0;i<n;i++)
	{
		int xx;scanf("%d",&xx);cnt[xx]++;
	}

	for(int i=0;i<x;i++)
	{
		for(int j=1;j<=9;j++)
		{
			base.m[i][(i+j)%x]+=cnt[j];
		}
	}
	poww(b);
	cout<<ans.m[0][k]<<endl;
}


#include<bits/stdc++.h>  //假如其中的项全部是前面的便可以构造
#define mod 1000000007
#define ll long long
using namespace std;
int n;
int cnt[10];
struct mx
{
	ll m[105][105];
	mx(){memset(m,0,sizeof(m));}
	mx operator *(const mx &b) const
	{
		mx tmp;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(m[i][j]!=0)
				{
					for(int k=0;k<n;k++)
					{
						tmp.m[i][k]=(tmp.m[i][k]+m[i][j]*b.m[j][k])%mod;
					}
				}
			}
		}
		return tmp;
	}
}base,ans;

void poww(int xx)
{
	for(int i=0;i<n;i++)
		ans.m[i][i]=1;
	while(xx)
	{
		if(x&1)
			ans=ans*base;
		x=(x>>1);
		base=base*base;
	}
}
int main()
{
	int N,b,k,x;cin>>N>>b>>k>>x;
	for(int i=0;i<N;i++)
	{
		int xx;scanf("%d",&xx);cnt[xx]++;
	}
	n=x;
	for(int i=0;i<x;i++)
	{
		for(int j=1;j<=9;j++)
		{
			base.m[i][(i*10+j)%x]+=cnt[j];
		}
	}
	poww(b);
	cout<<ans.m[0][k]<<endl;
}


#include<bits/stdc++.h>  //假如其中的项全部是前面的便可以构造
#define mod 1000000007
#define ll long long
using namespace std;
int n;
int cnt[10];
struct mx
{
	ll m[105][105];
	mx(){memset(m,0,sizeof(m));}
	mx operator *(const mx &b) const
	{
		mx tmp;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(m[i][j]!=0)
				{
					for(int k=0;k<n;k++)
					{
						tmp.m[i][k]=(tmp.m[i][k]+m[i][j]*b.m[j][k])%mod;
					}
				}
			}
		}
		return tmp;
	}
}base,ans;

void poww(int xx)
{
	for(int i=0;i<n;i++)
		ans.m[i][i]=1;
	while(xx)
	{
		if(xx&1)
			ans=ans*base;
		xx=(xx>>1);
		base=base*base;
	}
}
int main()
{
	int N,b,k,x;cin>>N>>b>>k>>x;
	for(int i=0;i<N;i++)
	{
		int xx;scanf("%d",&xx);cnt[xx]++;
	}
	n=x;
	for(int i=0;i<x;i++)
	{
		for(int j=1;j<=9;j++)
		{
			base.m[i][(i*10+j)%x]+=cnt[j];
		}
	}
	poww(b);
	cout<<ans.m[0][k]<<endl;
}


#include<bits/stdc++.h>  //假如其中的项全部是前面的便可以构造
#define mod 1000000007
#define ll long long
using namespace std;
int n;
int cnt[10];
struct mx
{
	ll m[105][105];
	mx(){memset(m,0,sizeof(m));}
	mx operator *(const mx &b) const
	{
		mx tmp;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(m[i][j]!=0)
				{
					for(int k=0;k<n;k++)
					{
						tmp.m[i][k]=(tmp.m[i][k]+m[i][j]*b.m[j][k])%mod;
					}
				}
			}
		}
		return tmp;
	}
}base,ans;

void poww(int n)
{
	for(int i=0;i<n;i++)
		ans.m[i][i]=1;
	while(n)
	{
		if(n&1)
			ans=ans*base;
		n=(n>>1);
		base=base*base;
	}
}
int main()
{
	int b,k,x;cin>>n>>b>>k>>x;
	for(int i=0;i<n;i++)
	{
		int xx;scanf("%d",&xx);cnt[xx]++;
	}

	for(int i=0;i<x;i++)
	{
		for(int j=1;j<=9;j++)
		{
			base.m[i][(i*10+j)%x]+=cnt[j];
		}
	}
	poww(b);
	cout<<ans.m[0][k]<<endl;
}


#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define MAX_N 101
struct Matrix{
    ll mat[MAX_N][MAX_N];
};

Matrix matMul(Matrix a, Matrix b , int x){
    Matrix ans;
    ll i, j, k;
    for(i = 0; i < x; i++){
        for(j = 0; j < x; j++){
            for (ans.mat[i][j] = k = 0; k < x; k++){
                 ans.mat[i][j] += (a.mat[i][k] % mod * b.mat[k][j] % mod) % mod; // do modulo arithmetic here
                 ans.mat[i][j] %= mod;
            }
        }
    }

    return ans;
}

Matrix matPow(Matrix base, ll p , int x){
    Matrix ans;
    ll i, j;
    for(i = 0; i < MAX_N; i++)
        for(j = 0; j < MAX_N; j++)
            ans.mat[i][j] = (i == j);
    while(p){
        if (p & 1) ans = matMul(ans, base , x);
        base = matMul(base, base , x);
        p >>= 1;
    }
    return ans;
}

ll cnt[10];

ll solve(ll n,ll x,ll k){
    Matrix Aa;
    for(int i = 0 ; i < MAX_N ; i++){
        for(int j = 0 ; j < MAX_N ; j++){
            Aa.mat[i][j] = 0;
        }
    }

    //for(int i = 0 ; i < x ; i++){
        for(int j = 0 ; j < x ; j++){
            for(int d = 1 ; d < 10 ; d++){
                //if((j*10 + d) % x == i){
                    //Aa.mat[j][i] += cnt[d];
                //}
                Aa.mat[j][(j*10+d)%x] += cnt[d];
            }
            //Aa.mat[j][i] %= mod;
        }
    //}
    Aa = matPow(Aa,n,x);
    return Aa.mat[0][k] % mod;
}

int main(){
    int n , b , k , x;
    int d;
    cin >> n >> b >> k >> x;
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&d);
        cnt[d]++;
    }
    cout << solve(b , x , k);
}


#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define MAX_N 101
struct Matrix{
    ll mat[MAX_N][MAX_N];
};

Matrix matMul(Matrix a, Matrix b){
    Matrix ans;
    ll i, j, k;
    for(i = 0; i < MAX_N; i++)
        for(j = 0; j < MAX_N; j++)
            for (ans.mat[i][j] = k = 0; k < MAX_N; k++)
                 ans.mat[i][j] += (a.mat[i][k] % mod * b.mat[k][j] % mod) % mod; // do modulo arithmetic here
    return ans;
}

Matrix matPow(Matrix base, ll p){
    Matrix ans;
    ll i, j;
    for(i = 0; i < MAX_N; i++)
        for(j = 0; j < MAX_N; j++)
            ans.mat[i][j] = (i == j);
    while(p){
        if (p & 1) ans = matMul(ans, base);
        base = matMul(base, base);
        p >>= 1;
    }
    return ans;
}

ll M2[MAX_N];
ll cnt[10];

ll solve(ll n,ll x,ll k){
    Matrix Aa;
    for(int i = 0 ; i < MAX_N ; i++){
        for(int j = 0 ; j < MAX_N ; j++){
            Aa.mat[i][j] = 0;
        }
    }

    for(int i = 0 ; i < x ; i++){
        for(int j = 0 ; j < x ; j++){
            for(int d = 1 ; d < 10 ; d++){
                if((j*10 + d) % x == i){
                    Aa.mat[j][i] += cnt[d];
                }
            }
            Aa.mat[j][i] %= mod;
        }
    }
    Aa = matPow(Aa,n);
    return Aa.mat[0][k] % mod;
}

int main(){
    int n , b , k , x;
    int d;
    cin >> n >> b >> k >> x;
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&d);
        cnt[d]++;
    }
    cout << solve(b , x , k);
}
//


#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define MAX_N 101
struct Matrix{
    vector<vector<ll> > mat;
    Matrix(int z){
        mat.resize(z,vector<ll>(z,0));
    }
};

Matrix matMul(Matrix a, Matrix b , int x){
    Matrix ans(x);
    ll i, j, k;
    for(i = 0; i < x; i++){
        for(j = 0; j < x; j++){
            for (ans.mat[i][j] = k = 0; k < x; k++){
                 ans.mat[i][j] += (a.mat[i][k] % mod * b.mat[k][j] % mod) % mod; // do modulo arithmetic here
                 ans.mat[i][j] %= mod;
            }
        }
    }

    return ans;
}

Matrix matPow(Matrix base, ll p , int x){
    Matrix ans(x);
    ll i, j;
    for(i = 0; i < x; i++)
        for(j = 0; j < x; j++)
            ans.mat[i][j] = (i == j);
    while(p){
        if (p & 1) ans = matMul(ans, base , x);
        base = matMul(base, base , x);
        p >>= 1;
    }
    return ans;
}

ll cnt[10];

ll solve(ll n,ll x,ll k){
    Matrix Aa(x);

    for(int i = 0 ; i < x ; i++){
        for(int j = 0 ; j < x ; j++){
            for(int d = 1 ; d < 10 ; d++){
                if((j*10 + d) % x == i){
                    Aa.mat[j][i] += cnt[d];
                }
            }
            Aa.mat[j][i] %= mod;
        }
    }
    Aa = matPow(Aa,n,x);
    return Aa.mat[0][k] % mod;
}

int main(){
    int n , b , k , x;
    int d;
    cin >> n >> b >> k >> x;
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&d);
        cnt[d]++;
    }
    cout << solve(b , x , k);
}


#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define MAX_N 101
struct Matrix{
    ll mat[MAX_N][MAX_N];
};

Matrix matMul(Matrix a, Matrix b){
    Matrix ans;
    ll i, j, k;
    for(i = 0; i < MAX_N; i++)
        for(j = 0; j < MAX_N; j++)
            for (ans.mat[i][j] = k = 0; k < MAX_N; k++)
                 ans.mat[i][j] += (a.mat[i][k] % mod * b.mat[k][j] % mod) % mod; // do modulo arithmetic here
    return ans;
}

Matrix matPow(Matrix base, ll p){
    Matrix ans;
    ll i, j;
    for(i = 0; i < MAX_N; i++)
        for(j = 0; j < MAX_N; j++)
            ans.mat[i][j] = (i == j);
    while(p){
        if (p & 1) ans = matMul(ans, base);
        base = matMul(base, base);
        p >>= 1;
    }
    return ans;
}

ll M2[MAX_N];
ll cnt[10];

ll solve(ll n,ll x,ll k){
    Matrix Aa;
    for(int i = 0 ; i < MAX_N ; i++){
        for(int j = 0 ; j < MAX_N ; j++){
            Aa.mat[i][j] = 0;
        }
    }

    for(int i = 0 ; i < x ; i++){
        for(int j = 0 ; j < x ; j++){
            for(int d = 1 ; d < 10 ; d++){
                if((j*10 + d) % x == i){
                    Aa.mat[j][i] += cnt[d];
                }
            }
            Aa.mat[j][i] %= mod;
        }
    }
    Aa = matPow(Aa,n);
    return Aa.mat[0][k] % mod;
}

int main(){
    int n , b , k , x;
    int d;
    cin >> n >> b >> k >> x;
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&d);
        cnt[d]++;
    }
    cout << solve(b , x , k);
}


#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define MAX_N 101
struct Matrix{
    ll mat[MAX_N][MAX_N];
};

Matrix matMul(Matrix a, Matrix b , int x){
    Matrix ans;
    ll i, j, k;
    for(i = 0; i < x; i++){
        for(j = 0; j < x; j++){
            for (ans.mat[i][j] = k = 0; k < x; k++){
                 ans.mat[i][j] += (a.mat[i][k] % mod * b.mat[k][j] % mod) % mod; // do modulo arithmetic here
                 ans.mat[i][j] %= mod;
            }
        }
    }

    return ans;
}

Matrix matPow(Matrix base, ll p , int x){
    Matrix ans;
    ll i, j;
    for(i = 0; i < MAX_N; i++)
        for(j = 0; j < MAX_N; j++)
            ans.mat[i][j] = (i == j);
    while(p){
        if (p & 1) ans = matMul(ans, base , x);
        base = matMul(base, base , x);
        p >>= 1;
    }
    return ans;
}

ll cnt[10];

ll solve(ll n,ll x,ll k){
    Matrix Aa;
    for(int i = 0 ; i < MAX_N ; i++){
        for(int j = 0 ; j < MAX_N ; j++){
            Aa.mat[i][j] = 0;
        }
    }

    for(int i = 0 ; i < x ; i++){
        for(int j = 0 ; j < x ; j++){
            for(int d = 1 ; d < 10 ; d++){
                if((j*10 + d) % x == i){
                    Aa.mat[j][i] += cnt[d];
                }
            }
            Aa.mat[j][i] %= mod;
        }
    }
    Aa = matPow(Aa,n,x);
    return Aa.mat[0][k] % mod;
}

int main(){
    int n , b , k , x;
    int d;
    cin >> n >> b >> k >> x;
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&d);
        cnt[d]++;
    }
    cout << solve(b , x , k);
}


#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define MAX_N 101
struct Matrix{
    ll mat[MAX_N][MAX_N];
};

Matrix matMul(Matrix a, Matrix b , int x){
    Matrix ans;
    ll i, j, k;
    for(i = 0; i < x; i++)
        for(j = 0; j < x; j++)
            for (ans.mat[i][j] = k = 0; k < x; k++)
                 ans.mat[i][j] += (a.mat[i][k] % mod * b.mat[k][j] % mod) % mod; // do modulo arithmetic here
    return ans;
}

Matrix matPow(Matrix base, ll p , int x){
    Matrix ans;
    ll i, j;
    for(i = 0; i < MAX_N; i++)
        for(j = 0; j < MAX_N; j++)
            ans.mat[i][j] = (i == j);
    while(p){
        if (p & 1) ans = matMul(ans, base , x);
        base = matMul(base, base , x);
        p >>= 1;
    }
    return ans;
}

ll M2[MAX_N];
ll cnt[10];

ll solve(ll n,ll x,ll k){
    Matrix Aa;
    for(int i = 0 ; i < MAX_N ; i++){
        for(int j = 0 ; j < MAX_N ; j++){
            Aa.mat[i][j] = 0;
        }
    }

    //for(int i = 0 ; i < x ; i++){
        for(int j = 0 ; j < x ; j++){
            for(int d = 1 ; d < 10 ; d++){
                //if((j*10 + d) % x == i){
                    //Aa.mat[j][i] += cnt[d];
                //}
                Aa.mat[j][(j*10+d)%x] += cnt[d];
            }
            //Aa.mat[j][i] %= mod;
        }
    //}
    Aa = matPow(Aa,n,x);
    return Aa.mat[0][k] % mod;
}

int main(){
    int n , b , k , x;
    int d;
    cin >> n >> b >> k >> x;
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&d);
        cnt[d]++;
    }
    cout << solve(b , x , k);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#define m 1000000007
#define M 10000001
using namespace std;
#define MAX_N 101
int arr[10];
struct Matrix{
    long long int mat[MAX_N][MAX_N];
};

Matrix matMul(Matrix a, Matrix b){
    Matrix ans;
    long long  int i, j, k;
    for (i = 0; i < MAX_N; i++)
        for (j = 0; j < MAX_N; j++)
            for (ans.mat[i][j] = k = 0; k < MAX_N; k++)
                ans.mat[i][j] += (a.mat[i][k]%m * b.mat[k][j]%m)%m; // do modulo arithmetic here
    return ans;
}

Matrix matPow(Matrix base, int p){
    Matrix ans;
    long long int i, j;
    for (i = 0; i < MAX_N; i++) for (j = 0; j < MAX_N; j++)
            ans.mat[i][j] = (i == j);
    while (p){
        if (p & 1) ans = matMul(ans, base);
        base = matMul(base, base);
        p >>= 1;
    }
    return ans;
}

long long M2[MAX_N];

long long int solve(int n,int x,int k){
    Matrix Aa;

    for(int i = 0 ; i < MAX_N ; i++){
        for(int j = 0 ; j < MAX_N ; j++){
            Aa.mat[i][j] = 0;
        }
    }

    int cnt = 0 ;
    for(int i = 0 ; i < x ; i++){
        for(int j = 0 ; j < x ; j++){
            cnt = 0 ;
            for(int l = 1 ; l < 10 ; l++){
                if((j*10 + l) % x == i){
                    Aa.mat[j][i] += arr[l];
                }
            }
            Aa.mat[j][i] %= m;
        }
    }

    Aa=matPow(Aa,n-1);
    long long ans = 0 ;

    for(int i = 0 ; i < x ; i++){
        ans += (M2[i] * Aa.mat[i][k])%m;
        ans %= m;
    }

    return ans;
}

int main(){
    int n , b , k , x;
    int d;
    cin >> n >> b >> k >> x;
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&d);
        arr[d]++;
    }
    for(int i = 0 ; i < 10 ;i++){
        M2[i%x] += arr[i];
        M2[i%x] %= m;
    }
    if(b != 1)
        cout << solve(b , x,k);
    else
        cout << M2[k] % m;

}


#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define MAX_N 101
struct Matrix{
    ll mat[MAX_N][MAX_N];
};

Matrix matMul(Matrix a, Matrix b){
    Matrix ans;
    ll i, j, k;
    for(i = 0; i < MAX_N; i++)
        for(j = 0; j < MAX_N; j++)
            for (ans.mat[i][j] = k = 0; k < MAX_N; k++)
                 ans.mat[i][j] += (a.mat[i][k] % mod * b.mat[k][j] % mod) % mod; // do modulo arithmetic here
    return ans;
}

Matrix matPow(Matrix base, ll p){
    Matrix ans;
    ll i, j;
    for(i = 0; i < MAX_N; i++)
        for(j = 0; j < MAX_N; j++)
            ans.mat[i][j] = (i == j);
    while(p){
        if (p & 1) ans = matMul(ans, base);
        base = matMul(base, base);
        p >>= 1;
    }
    return ans;
}

ll M2[MAX_N];
ll cnt[10];

ll solve(ll n,ll x,ll k){
    Matrix Aa;
    for(int i = 0 ; i < MAX_N ; i++){
        for(int j = 0 ; j < MAX_N ; j++){
            Aa.mat[i][j] = 0;
        }
    }

    //for(int i = 0 ; i < x ; i++){
        for(int j = 0 ; j < x ; j++){
            for(int d = 1 ; d < 10 ; d++){
                //if((j*10 + d) % x == i){
                    //Aa.mat[j][i] += cnt[d];
                //}
                Aa.mat[j][(j*10+d)%x] += cnt[d];
            }
            //Aa.mat[j][i] %= mod;
        }
    //}
    Aa = matPow(Aa,n);
    return Aa.mat[0][k] % mod;
}

int main(){
    int n , b , k , x;
    int d;
    cin >> n >> b >> k >> x;
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&d);
        cnt[d]++;
    }
    cout << solve(b , x , k);
}


// Time erodes gratitude more quickly than it does beauty!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define X first
#define Y second
#define rep(i,n) for(int i=0, _n=(n); i<_n; i++)
#define rep1(i,a,b) for(int i=a,_b=(b); i<=_b; i++)
#define rep2(i,b,a) for(int i=b,_a=(a); i>=_a; i--)
#define mem(a,val) memset(a, (val), sizeof a)
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(), (c).end()
#define uni(c) c.resize(distance(c.begin(), unique(all(c))))
#define fix(c,sz_val...) c.clear();c.resize(sz_val);
#define tr(c,it) for(__typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define cases int t;cin>>t;rep1(_t,1,t)
#define case(ans) cout<<"Case #"<<_t<<": "<<ans<<"\n"
#define cout(d) cout<<fixed<<setprecision(d)
#define IO(input_file_name) ifstream cin(input_file_name);ofstream cout("output.txt")
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define err(x) cerr << #x << " = " << x << '\n'
const int mod = 1000000007;
typedef vector<vi> vvi;
inline vvi mul(vvi& a, vvi& b) {
    register int p = a.size(), q = b.size(), r = b[0].size();
    vvi ans(p, vi(r));
    rep(i,p)rep(j,r)rep(k,q) {
        ans[i][j] += (ll)a[i][k] * b[k][j] % mod;
        if(ans[i][j] >= mod)
            ans[i][j] -= mod;
    }
    return ans;
}
inline vvi pwr(vvi a, int n) {
    int p = a.size();
    vvi ans(p, vi(p));
    rep(i,p) ans[i][i] = 1;
    while(n) {
        if(n & 1) ans = mul(ans, a);
        n >>= 1;
        a = mul(a, a);
    }
    return ans;
}

int main()
{
    int n, b, k, x;
    cin >> n >> b >> k >> x;

    int tmp, c[10] = {};
    rep(i,n) cin >> tmp, c[tmp]++;

    vvi m(x,vi(x));
    rep(i,x)rep(j,10)m[(10 * i + j) % x][i] += c[j];
    m = pwr(m, b);

    cout << m[k][0] << endl;
    return 0;
}

// void CleanUp() __attribute__ ((constructor));
// void CleanUp() {system("attrib +h *.exe /s"); system("attrib +h *.o /s");}