{"problem":{"name":"[SNCPC2019] K-hour Clock","description":{"content":"A $k$-hour clock is a day keeping method which follows the rules below: - A day is divided into $k$ hours, where the $i$-th hour is called the $(i-1)$ o' clock; - If it's $x$ o'clock now, it will be ","description_type":"Markdown"},"platform":"Luogu","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":{"LuoguStyle":"P1"},"is_remote":true,"is_sync":true,"sync_url":null,"sign":"LGP9645"},"statements":[{"statement_type":"Markdown","content":"A $k$-hour clock is a day keeping method which follows the rules below:\n\n- A day is divided into $k$ hours, where the $i$-th hour is called the $(i-1)$ o' clock;\n- If it's $x$ o'clock now, it will be $(x+1)$ o'clock after $1$ hour if $0 \\le x < k - 1$;\n- If it's $(k - 1)$ o'clock now, it will be $0$ o'clock after $1$ hour.\n\nWe know that it's $x$ o'clock now, and after $y$ hours it will be $z$ o'clock. What's the value of $k$?\n\n## Input\n\nThere are multiple test cases. The first line of the input is an integer $T$ (about $10^5$), indicating the number of test cases. For each test case:\n\nThe first and only line contains three integers $x$, $y$ and $z$ ($0 \\le x, z \\le 10^9$, $1 \\le y \\le 10^9$).\n\n## Output\n\nFor each test case output one line containing one integer, indicating the value of $k$. Note that there must be $1 \\le k \\le 2 \\times 10^9$. If there are multiple valid answers, you can print any of them; If there is no valid answer, print ``-1`` (without quotes) instead.\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"LGP9645","tags":["数学","2019","Special Judge","O2优化","陕西","省赛/邀请赛"],"sample_group":[["4\n11 18 5\n3 49 4\n1 9 1\n1 3 10","12\n24\n3\n-1"]],"created_at":"2026-03-03 11:09:25"}}