{"raw_statement":[{"iden":"statement","content":"Archmage (AM for short) is a hero unit in WatercraftⅢ.\n\nHe has $n$ mana *at most* and two powerful skills which enable him to show great strength in battle:\n\nSince the power of an Archmage is tremendous, the upper limit of mana $n$ is always greater than or equal to $x + y$.\n\nEvery second, Archmage will summon *exactly one* Water Element (if the mana is enough, i.e., his mana won't be less than $0$ after that) or do nothing. Then no matter what he did before, he will restore $y$ mana.\n\nArchmage has $n$ mana at the end of the second $0$, and the game starts at the beginning of the second $1$.\n\nHe wants to know how many Water Elements he can summon at most before the end of the second $m$.\n\nThe input consists of multiple test cases. \n\nThe first line contains a single integer $t (1 <= t <= 10^5)$, indicating the number of test cases.\n\nEach of the next $t$ lines contains $4$ integers $n, m, x, y (1 <= m, x, y <= 10^9, x + y <= n <= 2 times 10^9)$.\n\nFor each test case, output the answer in a line.\n\nIn test case $1$, Archmage can cast spells every second, so the answer is $2$.\n\nIn test case $2$, here's a way for Archmage to cast spells $3$ times.\n\nSecond $1$: Archmage cast spells, and there is $4 -x + y = 3$ mana left.\n\nSecond $2$: Archmage cast spells, and there is $3 -x + y = 2$ mana left.\n\nSecond $3$: Archmage cast spells, and there is $2 -x + y = 1$ mana left.\n\nSecond $4$: Archmage doesn't have enough mana so he can do nothing, and there is $1 + y = 2$ mana left.\n\n"},{"iden":"input","content":"The input consists of multiple test cases. The first line contains a single integer $t (1 <= t <= 10^5)$, indicating the number of test cases.Each of the next $t$ lines contains $4$ integers $n, m, x, y (1 <= m, x, y <= 10^9, x + y <= n <= 2 times 10^9)$."},{"iden":"output","content":"For each test case, output the answer in a line."},{"iden":"note","content":"In test case $1$, Archmage can cast spells every second, so the answer is $2$.In test case $2$, here's a way for Archmage to cast spells $3$ times.Second $1$: Archmage cast spells, and there is $4 -x + y = 3$ mana left.Second $2$: Archmage cast spells, and there is $3 -x + y = 2$ mana left.Second $3$: Archmage cast spells, and there is $2 -x + y = 1$ mana left.Second $4$: Archmage doesn't have enough mana so he can do nothing, and there is $1 + y = 2$ mana left."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case, let $ N, M, X, Y \\in \\mathbb{Z} $ denote:  \n- $ N $: number of rows,  \n- $ M $: number of columns,  \n- $ (X, Y) $: coordinates of Mr. Manohar’s office.  \n\nThe auto follows the path:  \n- From $ (1,1) $ to $ (1,M) $ along row 1 (eastward),  \n- Then from $ (1,M) $ to $ (N,M) $ along column $ M $ (southward).  \n\nAt $ t = 0 $, four secret agents start at $ (X, Y) $ and move in fixed directions with rebound behavior:  \n- Agent 1: North (if possible), else South.  \n- Agent 2: South (if possible), else North.  \n- Agent 3: East (if possible), else West.  \n- Agent 4: West (if possible), else East.  \n\nEach agent moves 1 cell per second; upon hitting a grid boundary, it reverses direction immediately.  \n\n**Constraints**  \n1. $ 1 \\le T \\le 1000 $  \n2. $ 2 \\le N, M \\le 10^9 $  \n3. $ 1 \\le X \\le N $, $ 1 \\le Y \\le M $  \n\n**Objective**  \nDetermine if the auto’s path intersects any secret agent at the same cell at the same time $ t \\in \\mathbb{Z}_{\\ge 0} $.  \n\nThe auto’s position at time $ t $:  \n- For $ 0 \\le t < M $: $ (1, 1 + t) $  \n- For $ M \\le t \\le M + N - 1 $: $ (1 + (t - M), M) $  \n\nLet $ A_i(t) $ denote the position of agent $ i \\in \\{1,2,3,4\\} $ at time $ t $.  \n\n**Output**  \nPrint \"Farewell\" if $ \\forall t \\in [0, M + N - 1] $, auto’s position $ \\neq A_i(t) $ for all $ i \\in \\{1,2,3,4\\} $.  \nOtherwise, print \"BestWishes\".","simple_statement":"The auto travels from (1,1) to (1,M) then to (N,M).  \nFour agents start at (X,Y) at t=0, each moving in one direction (North, South, East, West), bouncing off walls.  \nIf any agent and the auto are in the same cell at the same time, the trip fails.  \nCheck if the auto can reach (N,M) without meeting any agent.","has_page_source":false}