{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eHilbert\u0027s hotel has infinitely many rooms, numbered 0, 1, 2, ... At most one guest occupies each room. Since people tend to check-in in groups, the hotel has a group counter variable $$$G$$$.\u003c/p\u003e\u003cp\u003eHilbert\u0027s hotel had a grand opening today. Soon after, infinitely many people arrived at once, filling every room in the hotel. All guests got the group number 0, and $$$G$$$ is set to 1.\u003c/p\u003e\u003cp\u003eIronically, the hotel can accept more guests even though every room is filled: \u003c/p\u003e\u003cul\u003e\u003cli\u003e If $$$k$$$ ($$$k \\geq 1$$$) people arrive at the hotel, then for each room number $$$x$$$, the guest in room $$$x$$$ moves to room $$$x+k$$$. After that, the new guests fill all the rooms from 0 to $$$k-1$$$. \u003c/li\u003e\u003cli\u003e If infinitely many people arrive at the hotel, then for each room number $$$x$$$, the guest in room $$$x$$$ moves to room $$$2x$$$. After that, the new guests fill all the rooms with odd numbers.\u003c/li\u003e\u003c/ul\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/63dbb71e4982d0d5d6fdaaaa688916b0?v\u003d1720095696\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e\u003cp\u003eYou have to write a program to process the following queries: \u003c/p\u003e\u003cul\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e1 k\u003c/span\u003e - If $$$k \\geq 1$$$, then $$$k$$$ people arrive at the hotel. If $$$k \u003d 0$$$, then infinitely many people arrive at the hotel. Assign the group number $$$G$$$ to the new guests, and then increment $$$G$$$ by 1. \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e2 g x\u003c/span\u003e - Find the $$$x$$$-th smallest room number that contains a guest with the group number $$$g$$$. Output it modulo $$$10^9 + 7$$$, followed by a newline. \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003e3 x\u003c/span\u003e - Output the group number of the guest in room $$$x$$$, followed by a newline.\u003c/li\u003e\u003c/ul\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eIn the first line, an integer $$$Q$$$ ($$$1 \\leq Q \\leq 300,000$$$) denoting the number of queries is given. Each of the next lines contains a query. All numbers in the queries are integers. \u003c/p\u003e\u003cul\u003e\u003cli\u003e For the \u003cspan class\u003d\"tex-font-style-tt\"\u003e1 k\u003c/span\u003e queries, $$$0 \\leq k \\leq 10^9$$$. \u003c/li\u003e\u003cli\u003e For the \u003cspan class\u003d\"tex-font-style-tt\"\u003e2 g x\u003c/span\u003e queries, $$$g \u0026lt; G$$$, $$$1 \\leq x \\leq 10^9$$$, and at least $$$x$$$ guests have the group number $$$g$$$. \u003c/li\u003e\u003cli\u003e For the \u003cspan class\u003d\"tex-font-style-tt\"\u003e3 x\u003c/span\u003e queries, $$$0 \\leq x \\leq 10^9$$$.\u003c/li\u003e\u003c/ul\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eProcess all queries and output as required. It is guaranteed that the output is not empty.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e10\n3 0\n1 3\n2 1 2\n1 0\n3 10\n2 2 5\n1 5\n1 0\n3 5\n2 3 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n1\n0\n9\n4\n4\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIf you know about \"cardinals,\" please assume that \"infinite\" refers only to \"countably infinite.\" If you don\u0027t know about it, then you don\u0027t have to worry.\u003c/p\u003e"}}]}