{"raw_statement":[{"iden":"problem statement","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."},{"iden":"constraints","content":"*   $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."},{"iden":"input","content":"The 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$"},{"iden":"sample input 1","content":"5\n5 10\n6 1\n6 10\n9 10\n123456789 111"},{"iden":"sample output 1","content":"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$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}