{"problem":{"name":"P. The Only Level","description":{"content":"A secret agent... to be one you have pushed both your physical and intellectual capacities, immersing yourself in the art of espionage. It is now time to prove your worth. Your name isn't Mario but y","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10253P"},"statements":[{"statement_type":"Markdown","content":"A secret agent... to be one you have pushed both your physical and intellectual capacities, immersing yourself in the art of espionage. It is now time to prove your worth.\n\nYour name isn't Mario but you end up falling down from a pipe.\n\nYou find an elephant in a room.\n\nIt speaks.\n\nYou expect a Sphinx to give out a riddle in this scenario, but the elephant gives you no time to be confused as it tells you:\n\n\"If you want to be a spy, you must pass the test.\"\n\nAfter a moment's hesitation, you find the words to reply. \"Yes, this is what I came here for. But is there anything else that I must do?\"\n\n\"No, this is the only level,\" the elephant assures you.\n\nIt gives you the test:\n\n\" The *digital sum* of an integer in base $b$ is the sum of its digits when it is written in base $b$. The *digital root* of an integer in base $b$ is the unique digit obtained by repeatedly computing the digital sum in base $b$ until only one digit remains. \n\nLet $f_b (k)$ be the digital root of the integer $k$ in base $b$.\n\nWe say that the pair $(k, b)$ is *cool* if and only if $(f_b (0), f_b (k), f_b (2 k), \\\\dots, f_b ((b -1) k))$ is a permutation of $(0, 1, 2, \\\\dots, b -1)$. \n\nGiven $k$ and $b$, is $(k, b)$ a cool pair? \"\n\nThe first line of input contains $t$, the number of test cases. \n\nEach test case consists of a single line containing two space-separated integers $k$ and $b$. \n\n*Constraints*\n\n$1 <= t <= 10^5$\n\n$1 <= k <= 10^(15)$\n\n$2 <= b <= 10^(15)$\n\nFor each test case, output a single line containing the string:\n\n## Input\n\nThe first line of input contains $t$, the number of test cases. Each test case consists of a single line containing two space-separated integers $k$ and $b$. *Constraints*$1 <= t <= 10^5$$1 <= k <= 10^(15)$$2 <= b <= 10^(15)$\n\n## Output\n\nFor each test case, output a single line containing the string:  \"_COOL_\" (without the quotes) if $(k, b)$ is a cool pair;  \"_NOT COOL_\" (without the quotes) if $(k, b)$ is not a cool pair. \n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ b \\in \\mathbb{Z}_{\\geq 2} $, $ k \\in \\mathbb{Z}_{\\geq 1} $.  \nLet $ f_b(k) $ denote the digital root of $ k $ in base $ b $, defined as the single digit obtained by iteratively summing the base-$ b $ digits of a number until a single digit remains.  \n\n**Constraints**  \n1. $ 1 \\leq t \\leq 10^5 $  \n2. For each test case:  \n   - $ 1 \\leq k \\leq 10^{15} $  \n   - $ 2 \\leq b \\leq 10^{15} $  \n\n**Objective**  \nFor given $ k $ and $ b $, determine whether the sequence  \n$$\n(f_b(0), f_b(k), f_b(2k), \\dots, f_b((b-1)k))\n$$  \nis a permutation of $ (0, 1, 2, \\dots, b-1) $.  \n\nOutput \"Yes\" if the pair $ (k, b) $ is *cool*, otherwise \"No\".","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10253P","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}