Problem: A 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] — are permutations, and [1, 1], [4, 3, 1], [2, 3, 4] — no.

Permutation 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] < 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.

The next permutation for a permutation a of length n — is the lexicographically smallest permutation b of length n that lexicographically larger than a. For example: 

  * for permutation [2, 1, 4, 3] the next permutation is [2, 3, 1, 4]; 
  * for permutation [1, 2, 3] the next permutation is [1, 3, 2]; 
  * for permutation [2, 1] next permutation does not exist. 



You are given the number n — the length of the initial permutation. The initial permutation has the form a = [1, 2, …, n]. In other words, a[i] = i (1 ≤ i ≤ n).

You need to process q queries of two types: 

  * 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]. 
  * 2 x: x times replace the current permutation with the next permutation. For example, if x=2 and the current permutation has the form [1, 3, 4, 2], then we should perform such a chain of replacements [1, 3, 4, 2] → [1, 4, 2, 3] → [1, 4, 3, 2]. 



For each query of the 1-st type output the required sum.

Input

The first line contains two integers n (2 ≤ n ≤ 2 ⋅ 10^5) and q (1 ≤ q ≤ 2 ⋅ 10^5), where n — the length of the initial permutation, and q — the number of queries.

The 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 ≤ l ≤ r ≤ n), the 2-nd type query consists of two integers 2 and x (1 ≤ x ≤ 10^5).

It is guaranteed that all requests of the 2-nd type are possible to process.

Output

For each query of the 1-st type, output on a separate line one integer — the required sum.

Example

Input


4 4
1 2 4
2 3
1 1 2
1 3 4


Output


9
4
6

Note

Initially, the permutation has the form [1, 2, 3, 4]. Queries processing is as follows: 

  1. 2 + 3 + 4 = 9; 
  2. [1, 2, 3, 4] → [1, 2, 4, 3] → [1, 3, 2, 4] → [1, 3, 4, 2]; 
  3. 1 + 3 = 4; 
  4. 4 + 2 = 6 

Solution (in JAVA):

Solution:
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Map.Entry;

import java.util.Random;
import java.util.TreeSet;

public final class CF_681_D2_D
{


	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void logWln(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputFlush(Object o){try {out.write(""+ o+"\n");out.flush();} catch (Exception e) {}}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}


	static void logBin(int[] tm) {for (int x:tm) logWln(bin(8,x)+" ");log("");}

	static String bin(int L,int x) {
		String s=Integer.toBinaryString(x);
		while (s.length()<L) s="0"+s;
		return s;
	}

	static long powerMod(long b,long e,long m){
		long x=1;
		while (e>0) {
			if (e%2==1)
				x=(b*x)%m;
			b=(b*b)%m;
			e=e/2;
		}
		return x; 
	}







	static long mod=1000000007;



	// Global vars
	static BufferedWriter out;
	static InputReader reader;

	static int[][] dd={{-1,0},{0,1},{1,0},{0,-1}};

	static int CX=26;

	static long[][] cache;;

	static int NX=3002;


	static class Composite implements Comparable<Composite>{
		int a;
		int b;
		int idx;

		public int compareTo(Composite X) {
			if (a!=X.a)
				return a-X.a;
			if (b!=X.b)
				return b-X.b;
			return idx-X.idx;
		}

		public Composite(int a, int b, int idx) {
			this.a = a;
			this.b = b;
			this.idx = idx;
		}


	}

	static long[] fact;

	// works with jump <= fact[8]
	static void transform(int[] map,long jump) {
		if (jump==0)  {
			//log(map);
			return;
		}
		int L=map.length;
		int i=L-1;
		if (map[i-1]>map[i]) {
			//log("case 1");
			while (i>0 && map[i]<map[i-1])
				i--;
			// need to find smallest than nxt

			int tgt=i;
			for (int j=i+1;j<L;j++) {
				if (map[j]>map[i-1] && map[j]<map[tgt])
					tgt=j;
			}
			int tm=map[i-1];
			map[i-1]=map[tgt];
			map[tgt]=tm;
			
			Arrays.sort(map,i,L);
			transform(map,jump-1);
			
		} else {
			//log("case 2");
			int cnt=1;
			//log("step 1");
			while (i>0 && map[i-1]<map[i] && fact[cnt+1]-1<=jump) {
				i--;
				cnt++;
				
			}
			//log("step 2");
		
			int u=i;
			int v=L-1;
			// reverse
			while (u<v) {
				int c=map[u];
				map[u]=map[v];
				map[v]=c;
				u++;
				v--;
			}
			//log("step 3");
			transform(map,jump-fact[cnt]+1);
			
		}

	}

	static int FX=11;

	static void process() throws Exception {

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader = new InputReader(System.in);

		fact=new long[FX];
		fact[0]=1;
		for (int i=1;i<FX;i++)
			fact[i]=fact[i-1]*i;
		
		int n=reader.readInt();
		int Q=reader.readInt();
		int [] a=new int[n];
		for (int i=0;i<n;i++)
			a[i]=i+1;
		
		long[] sum=new long[n];
		for (int i=0;i<n;i++) {
			if (i>0)
				sum[i]=sum[i-1];
			sum[i]+=a[i];
		}
			
		for (int q=0;q<Q;q++) {
			int t=reader.readInt();
			if (t==1) {
				int l=reader.readInt()-1;
				int r=reader.readInt()-1;
				long ans=sum[r];
				if (l>0)
					ans-=sum[l-1];
				output(ans);
				//logWln("ans:"+ans+" based on :");
				//log(a);
				
				
			} else {
				int jump=reader.readInt();
				transform(a,jump);
				// update
				int mn=Math.min(20, n);
				for (int i=n-mn;i<n;i++) {
					if (i>0)
						sum[i]=sum[i-1];
					else sum[i]=0;
					sum[i]+=a[i];
				}
			}
		}
	
		
		try {
			out.close();
		} catch (Exception Ex) {
		}

	}




	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final String readString(int L) throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder(L);
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}