{"trustable":false,"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":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\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\n\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\n\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\n\u003cul\u003e \n \u003cli\u003e for permutation [2, 1, 4, 3] the next permutation is [2, 3, 1, 4]; \u003c/li\u003e\n \u003cli\u003e for permutation [1, 2, 3] the next permutation is [1, 3, 2]; \u003c/li\u003e\n \u003cli\u003e for permutation [2, 1] next permutation does not exist. \u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eYou are given the number n\u0026nbsp;— the length of the initial permutation. The initial permutation has the form a \u003d [1, 2, ... n]. In other words, a[i] \u003d i (1 \u003c\u003d i \u003c\u003d n).\u003c/p\u003e\n\u003cp\u003eYou need to process q queries of two types: \u003c/p\u003e\n\u003cul\u003e \n \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] + ... + a[r]. \u003c/li\u003e\n \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] --\u003e [1, 4, 2, 3] --\u003e [1, 4, 3, 2]. \u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eFor each query of the 1-st type output the required sum.\u003c/p\u003e"}},{"title":"Türkçe Özet","value":{"format":"HTML","content":"\u003cp\u003eInitially, 1\u0027den n\u0027ye kadar sayıların sırayla bulunduğu bir dizimiz var. Soruda q tane sorgu var. Sorgular iki tip, birinci sorguda iki sayı veriyor ve dizide bu iki indis arasındaki sayıların toplamını ekrana basmanızı istiyor (verilen sayılar dahil). İkinci tip sorguda ise bir x tamsayısı veriyor ve diziyi x sonraki permütasyon haline getiriyor.\u003c/p\u003e\n\u003cp\u003e\nÖrneğin 1,2,3,4,5 dizisinde ikinci tip sorgu yapıldığında ve tamsayı olarak 1 verildiğinde dizi 1,2,3,5,4 halini alıyor. Bundan sonra 2 tamsayısı girilirse 1,2,4,5,3 halini alıyor. Bundan sonra birinci tip sorgu yapılırsa ve l\u003d2, r\u003d5 verilirse ekrana 2+3+5+4\u003d14 basmalısınız.\n\u003c/p\u003e\n\u003cp\u003e\nDaha iyi anlamak için örnek çıktıya ve açıklamasına bakın.\n\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two integers n (2 \u003c\u003d n \u003c\u003d 2 * 10^5) and q (1 \u003c\u003d q \u003c\u003d 2 * 10^5), where n\u0026nbsp;— the length of the initial permutation, and q\u0026nbsp;— the number of queries.\u003c/p\u003e\n\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 \u003c\u003d l \u003c\u003d r \u003c\u003d n), the 2-nd type query consists of two integers 2 and x (1 \u003c\u003d x \u003c\u003d 10^5).\u003c/p\u003e\n\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":"Example","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e4 4\n1 2 4\n2 3\n1 1 2\n1 3 4\n\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e9\n4\n6\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"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\n\u003col\u003e \n \u003cli\u003e 2 + 3 + 4 \u003d 9; \u003c/li\u003e\n \u003cli\u003e [1, 2, 3, 4] -\u003e [1, 2, 4, 3] -\u003e [1, 3, 2, 4] -\u003e [1, 3, 4, 2]; \u003c/li\u003e\n \u003cli\u003e 1 + 3 \u003d 4; \u003c/li\u003e\n \u003cli\u003e 4 + 2 \u003d 6 \u003c/li\u003e\n\u003c/ol\u003e"}}]}