{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eA permutation is a sequence of integers from $$$1$$$ to $$$n$$$ of length $$$n$$$ containing each number exactly once. For example, $$$[1]$$$, $$$[4, 3, 5, 1, 2]$$$, $$$[3, 2, 1]$$$\u0026nbsp;— are permutations, and $$$[1, 1]$$$, $$$[4, 3, 1]$$$, $$$[2, 3, 4]$$$\u0026nbsp;— no.\u003c/p\u003e\u003cp\u003ePermutation $$$a$$$ is lexicographically smaller than permutation $$$b$$$ (they have the same length $$$n$$$), if in the first index $$$i$$$ in which they differ, $$$a[i] \u0026lt; b[i]$$$. For example, the permutation $$$[1, 3, 2, 4]$$$ is lexicographically smaller than the permutation $$$[1, 3, 4, 2]$$$, because the first two elements are equal, and the third element in the first permutation is smaller than in the second.\u003c/p\u003e\u003cp\u003eThe next permutation for a permutation $$$a$$$ of length $$$n$$$\u0026nbsp;— is the lexicographically smallest permutation $$$b$$$ of length $$$n$$$ that lexicographically larger than $$$a$$$. For example: \u003c/p\u003e\u003cul\u003e \u003cli\u003e for permutation $$$[2, 1, 4, 3]$$$ the next permutation is $$$[2, 3, 1, 4]$$$; \u003c/li\u003e\u003cli\u003e for permutation $$$[1, 2, 3]$$$ the next permutation is $$$[1, 3, 2]$$$; \u003c/li\u003e\u003cli\u003e for permutation $$$[2, 1]$$$ next permutation does not exist. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou are given the number $$$n$$$\u0026nbsp;— the length of the initial permutation. The initial permutation has the form $$$a \u003d [1, 2, \\ldots, n]$$$. In other words, $$$a[i] \u003d i$$$ ($$$1 \\le i \\le n$$$).\u003c/p\u003e\u003cp\u003eYou need to process $$$q$$$ queries of two types: \u003c/p\u003e\u003cul\u003e \u003cli\u003e $$$1$$$ $$$l$$$ $$$r$$$: query for the sum of all elements on the segment $$$[l, r]$$$. More formally, you need to find $$$a[l] + a[l + 1] + \\ldots + a[r]$$$. \u003c/li\u003e\u003cli\u003e $$$2$$$ $$$x$$$: $$$x$$$ times replace the current permutation with the next permutation. For example, if $$$x\u003d2$$$ and the current permutation has the form $$$[1, 3, 4, 2]$$$, then we should perform such a chain of replacements $$$[1, 3, 4, 2] \\rightarrow [1, 4, 2, 3] \\rightarrow [1, 4, 3, 2]$$$. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor each query of the $$$1$$$-st type output the required sum.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two integers $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$) and $$$q$$$ ($$$1 \\le q \\le 2 \\cdot 10^5$$$), where $$$n$$$\u0026nbsp;— the length of the initial permutation, and $$$q$$$\u0026nbsp;— the number of queries.\u003c/p\u003e\u003cp\u003eThe next $$$q$$$ lines contain a single query of the $$$1$$$-st or $$$2$$$-nd type. The $$$1$$$-st type query consists of three integers $$$1$$$, $$$l$$$ and $$$r$$$ $$$(1 \\le l \\le r \\le n)$$$, the $$$2$$$-nd type query consists of two integers $$$2$$$ and $$$x$$$ $$$(1 \\le x \\le 10^5)$$$.\u003c/p\u003e\u003cp\u003eIt is guaranteed that all requests of the $$$2$$$-nd type are possible to process.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each query of the $$$1$$$-st type, output on a separate line one integer\u0026nbsp;— the required sum.\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\u003e4 4\n1 2 4\n2 3\n1 1 2\n1 3 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e9\n4\n6\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\u003eInitially, the permutation has the form $$$[1, 2, 3, 4]$$$. Queries processing is as follows: \u003c/p\u003e\u003col\u003e \u003cli\u003e $$$2 + 3 + 4 \u003d 9$$$; \u003c/li\u003e\u003cli\u003e $$$[1, 2, 3, 4] \\rightarrow [1, 2, 4, 3] \\rightarrow [1, 3, 2, 4] \\rightarrow [1, 3, 4, 2]$$$; \u003c/li\u003e\u003cli\u003e $$$1 + 3 \u003d 4$$$; \u003c/li\u003e\u003cli\u003e $$$4 + 2 \u003d 6$$$ \u003c/li\u003e\u003c/ol\u003e"}}]}