{"raw_statement":[{"iden":"statement","content":"_KazaQ_ wears socks every day.\n\nBefore the first day, he has $n$ pairs of socks in his closet, labeled from $1$ to $n$.\n\nEvery morning, he would put on a pair of socks with the smallest label in the closet.\n\nEvery evening, he would take off socks and put them into a basket. After that, if there are $(n -1)$ pairs of old socks in the basket, lazy _KazaQ_ will have to wash them. These socks can be dried out on the next day and then will be put back to the closet in the evening.\n\n_KazaQ_ would like to know which pair of socks he would wear on the $k$-th day.\n\nThe input contains multiple (about $2000$) test cases.\n\nEach test case in only one line contains two integers $n$, $k$ ($2 <= n <= 10^9$, $1 <= k <= 10^(18)$).\n\nFor each test case, output \"_Case #x: y_\" in one line (without quotes), where $x$ indicates the case number starting from $1$, and $y$ denotes the answer to the corresponding case.\n\n"},{"iden":"input","content":"The input contains multiple (about $2000$) test cases.Each test case in only one line contains two integers $n$, $k$ ($2 <= n <= 10^9$, $1 <= k <= 10^(18)$)."},{"iden":"output","content":"For each test case, output \"_Case #x: y_\" in one line (without quotes), where $x$ indicates the case number starting from $1$, and $y$ denotes the answer to the corresponding case."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the initial number of sock pairs, labeled $ 1 $ to $ n $.  \nLet $ k \\in \\mathbb{Z} $ be the target day.  \n\n**Constraints**  \n1. $ 2 \\leq n \\leq 10^9 $  \n2. $ 1 \\leq k \\leq 10^{18} $  \n\n**Process**  \n- Each morning, _KazaQ_ wears the sock pair with the smallest label in the closet.  \n- Each evening, worn socks are placed in a basket.  \n- When the basket contains $ n-1 $ pairs, they are washed and returned to the closet the next evening.  \n- Socks are reused in increasing order of label, cycling after all $ n $ pairs have been used.  \n\n**Objective**  \nFind the label of the sock pair worn on day $ k $.  \n\n**Pattern Analysis**  \nThe sock usage follows a periodic cycle:  \n- Days $ 1 $ to $ n $: wear pairs $ 1, 2, \\dots, n $ (first full cycle).  \n- After day $ n $, every $ n-1 $ days, the set $ \\{1, 2, \\dots, n-1\\} $ is reused (since pair $ n $ is held out until washed).  \n\nThus, after day $ n $, the cycle length is $ n-1 $, repeating the sequence $ 1, 2, \\dots, n-1 $.  \n\n**Formula**  \nLet $ k' = k - n $.  \n- If $ k \\leq n $, answer is $ k $.  \n- Else, answer is $ ((k' - 1) \\bmod (n - 1)) + 1 $.  \n\n**Final Expression**  \n$$\ny =\n\\begin{cases}\nk & \\text{if } k \\leq n \\\\\n((k - n - 1) \\bmod (n - 1)) + 1 & \\text{if } k > n\n\\end{cases}\n$$","simple_statement":"KazaQ has n pairs of socks. Each day he wears the smallest labeled pair available. After wearing, he puts them in a basket. When the basket has n-1 pairs, he washes them all, and they return to the closet the next evening. Find which pair he wears on day k.","has_page_source":false}