Vova is playing a computer game. There are in total $n$ turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is $k$.

During each turn Vova can choose what to do:   If the current charge of his laptop battery is strictly greater than $a$, Vova can just play, and then the charge of his laptop battery will decrease by $a$;  if the current charge of his laptop battery is strictly greater than $b$ ($b<a$), Vova can play and charge his laptop, and then the charge of his laptop battery will decrease by $b$;  if the current charge of his laptop battery is less than or equal to $a$ and $b$ at the same time then Vova cannot do anything and loses the game. 

Regardless of Vova's turns the charge of the laptop battery is always decreases.

Vova wants to complete the game (Vova can complete the game if after each of $n$ turns the charge of the laptop battery is strictly greater than $0$). Vova has to play exactly $n$ turns. Among all possible ways to complete the game, Vova wants to choose the one where the number of turns when he just plays (first type turn) is the maximum possible. It is possible that Vova cannot complete the game at all.

Your task is to find out the maximum possible number of turns Vova can just play (make the first type turn) or report that Vova cannot complete the game.

You have to answer $q$ independent queries.


-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 10^5$) — the number of queries. Each query is presented by a single line.

The only line of the query contains four integers $k, n, a$ and $b$ ($1 \le k, n \le 10^9, 1 \le b < a \le 10^9$) — the initial charge of Vova's laptop battery, the number of turns in the game and values $a$ and $b$, correspondingly.


-----Output-----

For each query print one integer: -1 if Vova cannot complete the game or the maximum number of turns Vova can just play (make the first type turn) otherwise.


-----Example-----
Input
6
15 5 3 2
15 5 4 3
15 5 2 1
15 5 5 1
16 7 5 2
20 5 7 3

Output
4
-1
5
2
0
1



-----Note-----

In the first example query Vova can just play $4$ turns and spend $12$ units of charge and then one turn play and charge and spend $2$ more units. So the remaining charge of the battery will be $1$.

In the second example query Vova cannot complete the game because even if he will play and charge the battery during each turn then the charge of the laptop battery will be $0$ after the last turn.

Difficulty: introductory

Starter code:

Solutions:
q = int(input())
for query in range(q):
	k, n, a, b = list(map(int,input().split()))
	if n * b > k:  
		print(-1)
	else:
		print(min(n, (k-n*b-1)//(a-b)))


def main():
    import sys
    input = sys.stdin.readline
    
    def solve():
        k, n, a, b = map(int, input().split())
        
        if k <= n * b:
            print(-1)
            return
        
        l = 0
        r = n + 1
        while r - l != 1:
            m = l + r >> 1
            K = k - a * m
            if K <= 0 or K <= b * (n - m):
                r = m
            else:
                l = m
        print(l)
    
    for _ in range(int(input())):
        solve()
    
    return 0

main()

import sys
input = sys.stdin.readline
Q = int(input())
for _ in range(Q):
    K, N, A, B = map(int, input().split())
    if B*N >= K:
        print(-1)
    elif A*N < K:
        print(N)
    else:
        print(-((-(K-B*N))//(A-B))-1)

for i in range(int(input())):
    k, n, a, b = list(map(int, input().split()))
    if k <= n * b:
        print(-1)
        continue
    if (k - n * b) % (a - b) == 0:
        print(min((k - n * b) // (a - b) - 1, n))
    else:
        print(min(int((k - n * b) / (a - b)), n))


#570_C

import math

cases = int(input())

for i in range(0, cases):
    ln = [int(i) for i in input().split(" ")]
    k = ln[0]
    t = ln[1]
    a = ln[2]
    b = ln[3]
    if k / t <= b:
        print(-1)
    else:
        num = b * t
        turns = (k - num) / (a - b)
        if turns % 1 == 0:
            print(min(t, int(turns) - 1))
        else:
            print(min(t, math.floor(turns)))
        


from sys import stdin
n=int(stdin.readline().strip())
for i in range(n):
    k,t,a,b=list(map(int,stdin.readline().strip().split()))
    low=0
    high=t
    while((high-low)>1):
        mid=(high+low)//2
        x=(t-mid)*b+(mid*a)
        if(x<k):
            low=mid
        else:
            high=mid

    x1=(t-high)*b+(high*a)
    x2=(t-low)*b+(low*a)
    if (x1<k):
        print(high)
    elif (x2<k):
        print(low)
    else:
        print(-1)
        
        


req = int(input())
for i in range(req):
    battery, amount, a, b = map(int, input().split())
    battery -= 1
    maximum = battery // b
    if maximum < amount:
        print(-1)
    else:
        c = a - b
        battery -= b * amount
        print(min(battery // c, amount))

q = int(input())
for _ in range(q):
    k, n, a, b = list(map(int, input().split()))
    if b * n >= k:
        print(-1)
        continue
    L = 0; R = n
    while R - L > 1:
        M = (L + R) // 2
        if a * M + b * (n - M) < k:
            L = M
        else:
            R = M
    if a * R + b * (n - R) < k:
        print(R)
    else:
        print(L)
        
        


for f in range(int(input())):
    k,n,a,b = [int(i) for i in input().split()]
    k -= 1
    q = (k - n*b)
    if q < 0:
        print(-1)
    else:
        print(min(q // (a-b), n))

#Bhargey Mehta (Sophomore)
#DA-IICT, Gandhinagar
import sys, math, queue, bisect
#sys.stdin = open("input.txt", "r")
MOD = 10**9+7
sys.setrecursionlimit(1000000)

for _ in range(int(input())):
    k, n, a, b = map(int, input().split())
    x = (k-n*b)//(a-b)
    if k <= n*b:
        print(-1)
    else:
        if (k-n*b)%(a-b) == 0:
            print(min(x-1, n))
        else:
            print(min(x, n))

SS = []
a = int(input())
for i in range(a):
    k, n, a, b = map(int, input().split())
    k -= n * b
    if k > 0:
        ll = k // (a - b)
        if k % (a - b) == 0:
            ll -= 1
        SS.append(min(ll, n))
    else:
        SS.append(-1)
for s in SS:
    print(s)

for _ in range(int(input())):
    k, n, a, b = list(map(int, input().split()))
    if k <= b * n:
        print(-1)
        continue
    L = 0
    R = n + 1
    while R - L > 1:
        mid = (R + L) // 2
        if mid * a + (n - mid) * b < k:
            L = mid
        else:
            R = mid
    print(L)

from math import ceil


q = int(input())

for _ in range(q):
	k, n, a, b = list(map(int, input().split()))

	if b * n >= k:
		print(-1)
	else:
		d = a * n - k + 1
		if d <= 0:
			print(n)
		else:
			r = a - b
			print(n - ceil(d / r))


q=int(input())
for _ in range(q):
    k,n,a,b=map(int,input().split())
    ans=(k-b*n-1)//(a-b)
    #print(ans,k-b*n)
    if b*n>=k:
        print(-1)
    else:
        print(min(ans,n))

q = int(input())
for i in range(q):
	k, n, a, b = list(map(int, input().split()))
	if n * b >= k:
		print(-1)
		continue
	l = 0
	r = min(k // a + 1, n + 1)
	while r - l > 1:
		m = (r + l) // 2
		if ((k - a * m - 1) // b >= n - m) and k - a * m > 0:
			l = m
		else:
			r = m
	print(l)


T = int(input())
test = 0
while test<T:
    
    arr = input()
    K,N,a,b = [int(num) for num in arr.split(' ')]
    
    if N*b>=K:
        print(-1)
    else:
        s = N*b
        d = a-b
        
        m = (K-1-s)//d
        
        if m<=N:
            print(m)
        else:
            print(N)
            
        
    test += 1

for TT in range(1, int(input()) + 1):
    k, n, a, b = map(int, input().split())
    x = (k - n * b + (a - b - 1)) // (a - b) - 1
    x = min(x, n)
    x = max(x, -1)
    print(x)

import sys
input = sys.stdin.readline

Q=int(input())
for testcase in range(Q):
    k,n,a,b=list(map(int,input().split()))

    if k<=n*b:
        print(-1)
        continue

    print(min(n,(k-n*b-1)//(a-b)))
    
    


a = int(input())
for i in range(a):
    z,x,n,m = list(map(int, input().split()))
    if(x*m>=z):
        print(-1)
    else:
        print(min((z-m*x-1)//(n-m),x))


q = int(input())
for i in range(0, q):
    s = input()
    s = s.split()
    k = int(s[0])
    n = int(s[1])
    a = int(s[2])
    b = int(s[3])
    if k - b*n > 0:
        j = (k - b * n -1 ) / (a - b)
        if j > n:
            j = n
        print(int(j))
    else:
        print(-1)

import sys
q = int(input())
for _ in range(q):
    k, n, a, b = map(int, sys.stdin.readline().split())
    if k-1-n*b < 0:
        print(-1)
        continue
    print(min(n, (k-1-n*b) // (a-b)))

q = int(input())
for _ in range(q):
    k,n,a,b = map(int, input().split())
    can_complete = k > b*n
    jp = (k -b*n -1)//(a -b)
    if not can_complete:
        print(-1)
    else:
        print(min(n,jp))