There is a special offer in Vasya's favourite supermarket: if the customer buys $a$ chocolate bars, he or she may take $b$ additional bars for free. This special offer can be used any number of times.

Vasya currently has $s$ roubles, and he wants to get as many chocolate bars for free. Each chocolate bar costs $c$ roubles. Help Vasya to calculate the maximum possible number of chocolate bars he can get!


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of testcases.

Each of the next $t$ lines contains four integers $s, a, b, c~(1 \le s, a, b, c \le 10^9)$ — the number of roubles Vasya has, the number of chocolate bars you have to buy to use the special offer, the number of bars you get for free, and the cost of one bar, respectively.


-----Output-----

Print $t$ lines. $i$-th line should contain the maximum possible number of chocolate bars Vasya can get in $i$-th test.


-----Example-----
Input
2
10 3 1 1
1000000000 1 1000000000 1

Output
13
1000000001000000000



-----Note-----

In the first test of the example Vasya can buy $9$ bars, get $3$ for free, buy another bar, and so he will get $13$ bars.

In the second test Vasya buys $1000000000$ bars and gets $1000000000000000000$ for free. So he has $1000000001000000000$ bars.

Difficulty: interview

Starter code:

Solutions:
for _ in range(int(input())):
    s, a, b, c = list(map(int, input().split()))

    x = s // c
    x += b * (x // a)

    print(x)


t = int(input())
for i in range(t):
    s, a, b, c = map(int, input().split())
    x = s // c
    print(s // c + x // a * b)

t = int(input())
for i in range(t):
	s, a, b, c = map(int, input().split())
	print(s // c + (s // c) // a * b)

T = int(input())

for t in range(T):
    s, a, b, c = list(map(int, input().split()))
    x = s // c
    x += (x // a) * b
    print(x)


t = int(input())
for i in range(t):
    s, a, b, c = list(map(int, input().split()))
    ans = s // c
    ans += (ans // a) * b
    print(ans)

n = int(input())
for i in range(n):
    s, a, b, c = map(int, input().split())
    ans = s // c + (s // c) // a * b
    print(ans)

t = int(input())
for _ in range(t):
	s, a, b, c = map(int, input().split())
	can = s // c
	ans = can + (can // a * b)
	print(ans)

t = int(input())
for i in range(t):
	s, a, b, c = map(int, input().split())
	x = s // (a * c)
	ans = x * (a + b)
	s -= x * a * c
	ans += s // c
	print(ans)

n = int(input())
for i in range(n):
	s,a,b,c = list(map(int,input().split()))
	kol = s // c
	print(kol + kol // a * b)
	


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

for t in range(ii()):
    s, a, b, c = mi()
    n = s // c
    x = n // a
    ans = n + x * b
    print(ans)


#codeforces_1056A_live
gi = lambda : list(map(int,input().split()))
for k in range(gi()[0]):
	s,a,b,c = gi()
	print(s//c + ((s//c)//a)*b)

for _ in range(int(input())):
    s, a, b, c = map(int, input().split())
    buy = s // c
    print(buy + (buy // a) * b)

#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=int(input())
for tt in range(t):
    s,a,b,c= map(int, sys.stdin.readline().split(' '))
    ans=s//c
    ans+=((ans//a)*b)
    print(ans)
    #n=int(input())
    #a=list(map(int,sys.stdin.readline().split(' ')))
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

t = int(input())
for q in range(t):
    s, a, b, c = list(map(int, input().split()))
    print(s // c + (s // c) // a * b)


t = int(input())
for i in range(t):
    s, a, b, c = map(int, input().split())
    ans = s // (a * c) * (a + b)
    s %= (a * c)
    ans += s // c
    print(ans)

t = int(input())
for i in range(t):
    s,a,b,c = map(int, input().split())
    ans = s // c
    ans += (ans//a)*b
    print(ans)

def mainA():
    T = int(input())
    for i in range(T):
        s, a, b, c = map(int, input().split())
        ans = s // c
        ans += ans // a * b
        print(ans)

mainA()

t = int(input())
for i in range(t):
    s, a, b, c = map(int, input().split())
    q = s // c
    ans = (q // a) * (a + b) + (q % a)
    print(ans)

3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(S, A, B, C):
    cnt = S // C
    cnt += B * (cnt // A)
    return cnt


def main():
    T = int(inp())
    for _ in range(T):
        S, A, B, C = [int(e) for e in inp().split()]
        print(solve(S, A, B, C))


def __starting_point():
    main()

__starting_point()