{"problem":{"name":"Removal of Multiples","description":{"content":"Let $S$ be the set of all positive integers. Process $Q$ queries in order. The $i$\\-th query gives you an integer $A_i$ not less than $2$ and a positive integer $B_i$, so perform the following two ste","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc197_c"},"statements":[{"statement_type":"Markdown","content":"Let $S$ be the set of all positive integers.\nProcess $Q$ queries in order. The $i$\\-th query gives you an integer $A_i$ not less than $2$ and a positive integer $B_i$, so perform the following two steps in order.\n\n1.  Remove from $S$ all elements that are multiples of $A_i$.\n2.  Print the $B_i$\\-th smallest element of $S$. It can be shown that under the given constraints, $S$ contains at least $B_i$ elements at this point.\n\n## Constraints\n\n*   $1\\le Q\\le 10^5$\n*   $2\\le A_i\\le 10^9$\n*   $1\\le B_i\\le 10^5$\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$Q$\n$A_1$ $B_1$\n$\\vdots$\n$A_Q$ $B_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc197_c","tags":[],"sample_group":[["5\n5 10\n6 1\n6 10\n9 10\n123456789 111","12\n1\n14\n16\n178\n\nWhen the elements of $S$ are listed in ascending order, the beginning of the list evolves as follows.\n\n*   Initially, $S=\\lbrace 1,2,3,4,5,6,7,8,9,10,\\ldots\\rbrace$.\n*   The first query removes multiples of $5$, resulting in $S=\\lbrace1,2,3,4,6,7,8,9,11,12,\\ldots\\rbrace$.\n*   The second query removes multiples of $6$, resulting in $S=\\lbrace1,2,3,4,7,8,9,11,13,14,\\ldots\\rbrace$.\n*   The third query removes multiples of $6$, resulting in $S=\\lbrace1,2,3,4,7,8,9,11,13,14,\\ldots\\rbrace$.\n*   The fourth query removes multiples of $9$, resulting in $S=\\lbrace1,2,3,4,7,8,11,13,14,16,\\ldots\\rbrace$.\n*   The fifth query removes multiples of $123456789$, resulting in $S=\\lbrace1,2,3,4,7,8,11,13,14,16,\\ldots\\rbrace$."]],"created_at":"2026-03-03 11:01:13"}}