{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eArchmage (AM for short) is a hero unit in Watercraftâ…˘.\u003c/p\u003e\u003cp\u003eHe has $$$n$$$ mana \u003cspan class\u003d\"tex-font-style-bf\"\u003eat most\u003c/span\u003e and two powerful skills which enable him to show great strength in battle:\u003c/p\u003e\u003col\u003e \u003cli\u003e Use $$$x$$$ mana to summon a Water Element. \u003c/li\u003e\u003cli\u003e Brilliance Aura restores $$$y$$$ mana for AM in a second, and it is the \u003cspan class\u003d\"tex-font-style-bf\"\u003eonly\u003c/span\u003e way to restore mana. Since his mana cannot exceed the upper limit, the superfluous mana will dissipate. i.e., suppose you have $$$p$$$ mana before the restoration, your mana will become $$$\\min(p+y,n)$$$. \u003c/li\u003e\u003c/ol\u003e\u003cp\u003eSince the power of an Archmage is tremendous, the upper limit of mana $$$n$$$ is always greater than or equal to $$$x+y$$$.\u003c/p\u003e\u003cp\u003eEvery second, Archmage will summon \u003cspan class\u003d\"tex-font-style-bf\"\u003eexactly one\u003c/span\u003e Water Element (if the mana is enough, i.e., his mana won\u0027t be less than $$$0$$$ after that) or do nothing. Then no matter what he did before, he will restore $$$y$$$ mana.\u003c/p\u003e\u003cp\u003eArchmage has $$$n$$$ mana at the end of the second $$$0$$$, and the game starts at the beginning of the second $$$1$$$.\u003c/p\u003e\u003cp\u003eHe wants to know how many Water Elements he can summon at most before the end of the second $$$m$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input consists of multiple test cases. \u003c/p\u003e\u003cp\u003eThe first line contains a single integer $$$t(1 \\leq t \\leq 10^5)$$$, indicating the number of test cases.\u003c/p\u003e\u003cp\u003eEach of the next $$$t$$$ lines contains $$$4$$$ integers $$$n,m,x,y(1 \\leq m,x,y \\leq 10^9,x+y \\leq n \\leq 2 \\times 10^9)$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, output the answer in a line.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\n2 2 1 1\n4 4 2 1\n6 10 4 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n3\n6\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn test case $$$1$$$, Archmage can cast spells every second, so the answer is $$$2$$$.\u003c/p\u003e\u003cp\u003eIn test case $$$2$$$, here\u0027s a way for Archmage to cast spells $$$3$$$ times.\u003c/p\u003e\u003cp\u003eSecond $$$1$$$: Archmage cast spells, and there is $$$4-x+y\u003d3$$$ mana left.\u003c/p\u003e\u003cp\u003eSecond $$$2$$$: Archmage cast spells, and there is $$$3-x+y\u003d2$$$ mana left.\u003c/p\u003e\u003cp\u003eSecond $$$3$$$: Archmage cast spells, and there is $$$2-x+y\u003d1$$$ mana left.\u003c/p\u003e\u003cp\u003eSecond $$$4$$$: Archmage doesn\u0027t have enough mana so he can do nothing, and there is $$$1+y\u003d2$$$ mana left.\u003c/p\u003e"}}]}