{"raw_statement":[{"iden":"statement","content":"On Planet E, snails are born in infinitely deep wells!\n\nInitially a snail is at $n$ meters below the ground. During the daytime the snail try very hard to climb up, and goes up by $a$ meters. It can escape the well once it touches the ground. However during the night the snail has to sleep and falls back by $b$ meters. Hence it may happens that an unfortunate snail stucks in the well forever.\n\nCan you help the snails on Planet E to determine the number of days they need to escape the well?\n\nThe first line contains a positive integer $T$ ($T <= 10$), the number of testcases.\n\nEach testcase contains three integers $n, a, b$ ($1 <= n <= 1000$, $0 <= a <= 1000$, $0 <= b <= 1000$), the initial position of the snail, the length it climbs up during the daytime, and the length it falls during the night.\n\nFor each testcase, output a single line consisting of the number of days the snail need to escape the well. Output \"-1\" (without quotes) if it is impossible.\n\n"},{"iden":"input","content":"The first line contains a positive integer $T$ ($T <= 10$), the number of testcases.Each testcase contains three integers $n, a, b$ ($1 <= n <= 1000$, $0 <= a <= 1000$, $0 <= b <= 1000$), the initial position of the snail, the length it climbs up during the daytime, and the length it falls during the night."},{"iden":"output","content":"For each testcase, output a single line consisting of the number of days the snail need to escape the well. Output \"-1\" (without quotes) if it is impossible."}],"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 $ k \\in \\{1, \\dots, T\\} $, let:  \n- $ n_k \\in \\mathbb{Z}^+ $: initial depth below ground (meters),  \n- $ a_k \\in \\mathbb{Z}_{\\geq 0} $: daily climb (meters),  \n- $ b_k \\in \\mathbb{Z}_{\\geq 0} $: nightly fall (meters).  \n\n**Constraints**  \n1. $ 1 \\leq T \\leq 10 $  \n2. For each $ k $:  \n   - $ 1 \\leq n_k \\leq 1000 $  \n   - $ 0 \\leq a_k \\leq 1000 $  \n   - $ 0 \\leq b_k \\leq 1000 $  \n\n**Objective**  \nFor each test case $ k $, compute the minimal number of days $ d_k \\in \\mathbb{Z}^+ \\cup \\{-1\\} $ such that the snail escapes:  \n- On day $ d $, after climbing, the snail’s position $ \\geq 0 $.  \n- Position after $ d-1 $ full days and nights: $ -n_k + (d-1)(a_k - b_k) $  \n- After climbing on day $ d $: $ -n_k + (d-1)(a_k - b_k) + a_k \\geq 0 $  \n\nIf $ a_k = 0 $: escape impossible unless $ n_k = 0 $ (but $ n_k \\geq 1 $), so always impossible.  \nIf $ a_k \\leq b_k $ and $ n_k > a_k $: impossible (never escapes).  \nOtherwise: solve for minimal $ d_k $ satisfying:  \n$$\n-n_k + (d_k - 1)(a_k - b_k) + a_k \\geq 0\n$$  \n$$\n\\Rightarrow d_k \\geq 1 + \\frac{n_k - a_k}{a_k - b_k}\n$$  \nIf $ a_k > b_k $, then:  \n$$\nd_k = \\left\\lceil \\frac{n_k - a_k}{a_k - b_k} \\right\\rceil + 1\n$$  \nIf $ a_k \\leq b_k $ and $ n_k > a_k $, output $ -1 $.  \nIf $ n_k \\leq a_k $, then $ d_k = 1 $.","simple_statement":"A snail starts n meters underground. Each day it climbs up a meters, then at night slides down b meters. If it reaches or goes above ground during the day, it escapes. If it can never escape, output -1. How many days does it take?","has_page_source":false}