You are given an array a_1, a_2, …, a_n.

You need to perform q queries of the following two types:

  1. "MULTIPLY l r x" — for every i (l ≤ i ≤ r) multiply a_i by x.
  2. "TOTIENT l r" — print \varphi(∏ _{i=l}^{r} a_i) taken modulo 10^9+7, where \varphi denotes Euler's totient function. 



The [Euler's totient function](http://gg.gg/euler_totient) of a positive integer n (denoted as \varphi(n)) is the number of integers x (1 ≤ x ≤ n) such that \gcd(n,x) = 1.

Input

The first line contains two integers n and q (1 ≤ n ≤ 4 ⋅ 10^5, 1 ≤ q ≤ 2 ⋅ 10^5) — the number of elements in array a and the number of queries.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300) — the elements of array a.

Then q lines follow, describing queries in the format given in the statement.

  1. "MULTIPLY l r x" (1 ≤ l ≤ r ≤ n, 1 ≤ x ≤ 300) — denotes a multiplication query.
  2. "TOTIENT l r" (1 ≤ l ≤ r ≤ n) — denotes a query on the value of Euler's totient function. 



It is guaranteed that there is at least one "TOTIENT" query.

Output

For each "TOTIENT" query, print the answer to it.

Example

Input

4 4
5 9 1 2
TOTIENT 3 3
TOTIENT 3 4
MULTIPLY 4 4 3
TOTIENT 4 4


Output

1
1
2

Note

In the first example, \varphi(1) = 1 for the first query, \varphi(2) = 1 for the second query and \varphi(6) = 2 for the third one.
import java.io.*;
import java.util.*;

public class F implements Runnable{
	public static void main (String[] args) {new Thread(null, new F(), "_cf", 1 << 28).start();}

	int MOD = (int)1e9+7;
	
	public void run() {
		//try { new TestGenerator(); } catch (Exception e) {}
		FastScanner fs = new FastScanner();
		//try { fs = new FastScanner("testdata.out"); } catch (Exception e) {}
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		long start = System.nanoTime();
		
//		int[] test = {2, 3, 1, 5};
//		ST_ st_ = new ST_(test.length, test);
//		System.out.println(st_.query(0, test.length));
//		st_.update(0, 2, 5);
//		System.out.println(st_.query(0, test.length));
		
		int[] invs = new int[100];
		int[] primes = new int[100];
		int[] map = new int[401];
		int ptr = 0;
		for(int i = 2; i <= 300; i++) {
			boolean prime = true;
			for(int j = 2; j < i; j++) {
				if(i % j == 0) prime = false;
			}
			if(prime) {
				primes[ptr++] = i;
				map[i] = ptr-1;
				invs[ptr-1] = power(i, MOD-2);
			}
		}
		primes = Arrays.copyOfRange(primes, 0, ptr);
		invs = Arrays.copyOfRange(invs, 0, ptr);

		int[][] pf = new int[301][];
		for(int i = 1; i <= 300; i++) {
			int[] temp = new int[601];
			int cur = i;
			ptr = 0;
			for(int j = 2; j <= cur; j++) {
				if(cur%j != 0) continue;
				int count = 0;
				while(cur%j == 0) {
					count++;
					cur /= j;
				}
				temp[ptr++] = j; temp[ptr++] = count;
			}
			if(cur > 1) {
				temp[ptr++] = cur; temp[ptr++] = 1;
			}
			temp = Arrays.copyOfRange(temp, 0, ptr);
			pf[i] = temp;
		}

		int n = fs.nextInt(), q = fs.nextInt();
		int[] a = fs.nextIntArray(n);
		long[] msks = new long[n];
		for(int i = 0; i < n; i++) {
			long msk = buildMask(a[i], pf, map, primes);
			msks[i] = msk;
		}
		ST_ st = new ST_(n, a);
		ST_OR or = new ST_OR(n, msks);
		
		while(q-->0) {
			char type = fs.next().charAt(0);
			if(type == 'T') {
				int l = fs.nextInt(), r = fs.nextInt();
				long p1 = st.query(l-1, r);
				long msk = or.query(1, l-1, r-1);
				long prod = 1;
				for(int i = 0; i < primes.length; i++) {
					long on = (1L << i) & msk;
					if(on == 0) continue;
					prod = mult(prod, mult(primes[i]-1, invs[i]));
				}
				prod = mult(p1, prod);
				out.println(prod);
//				output.append(prod).append('\n');
			}
			else {
				int l = fs.nextInt(), r = fs.nextInt();
				int x = fs.nextInt();
				st.update(l-1, r, x);
				long msk = buildMask(x, pf, map, primes);
				or.update(1, l-1, r-1, msk);
			}
		}
//		out.println(output);
		//out.println("TIME " + (System.nanoTime()-start)/1000000);
		
		out.close();
	}
	
	long buildMask(int val, int[][] pf, int[] map, int[] primes) {
		long mask = 0;
		for(int i = 0; i < pf[val].length; i += 2) {
			mask |= (1L << map[pf[val][i]]);
		}
		return mask;
	}

	long mult(long a, long b) {
		a *= b;
		a %= MOD;
		return a;
	}
	
	int power (long x, long y) {
    	long res = 1;
    	x %= MOD;
    	while(y > 0) {
    		if(y % 2 == 1) {
    			res = (res * x) % MOD;
    		}
    		y = (y >> 1L);
    		x = (x * x) % MOD;
    	}
    	return (int)res;
    }
	
	//I don't entirely understand but it should be quick
	class ST_ {
		int n, h;
		long[] tree, lazy, dirty, size;
		ST_(int n, int[] vs) {
			this.n = n;
			while((1<<h) < n) h++;
			tree = new long[2*n];
			lazy = new long[2*n];
			size = new long[2*n];
			dirty = new long[2*n];
			for(int i = 0; i < n; i++) {
				tree[i+n] = vs[i];
				size[i+n] = 1;
			}
			for(int i = n-1; i > 0; i--) {
				size[i] = size[i+i]+size[i+i+1];
				tree[i] = mult(tree[i+i], tree[i+i+1]);
				lazy[i] = 1;
			}
		}
		long query(int l, int r) {
			if(l >= r) return 0;
			l += n; r += n;
			push(l); push(r-1);
			long lp = 1, rp = 1;
			for(; l < r; l /= 2, r /= 2) {
				if((l&1) > 0) lp = mult(lp, tree[l++]);
				if((r&1) > 0) rp = mult(rp, tree[--r]);
			}
			return mult(lp, rp);
		}
		void update(int l, int r, long v) {
			if(l >= r) return;
			l += n;
			r += n;
			push(l); push(r-1);
			int l0 = l, r0 = r;
			for(; l < r; l /= 2, r /= 2) {
				if((l&1) > 0) apply(l++, v);
				if((r&1) > 0) apply(--r, v);
			}
			build(l0); build(r0-1);
		}
		void push(int p) {
			for(int s = h; s > 0; s--) {
				int i = (p >> s);
				if(dirty[i] == 1) {
					apply(i+i, lazy[i]);
					apply(i+i+1, lazy[i]);
					dirty[i] = 0;
					lazy[i] = 1;
				}
			}
		}
		void apply(int p, long val) {
			tree[p] = mult(tree[p], power(val, size[p]));
			if(p < n) {
				dirty[p] = 1;
				lazy[p] = mult(lazy[p], val);
			}
		}
		void build(int p) {
			for(p /= 2; p > 0; p /= 2) {
				tree[p] = mult(tree[p+p], tree[p+p+1]);
				if(dirty[p] == 1) {
					tree[p] = mult(tree[p], power(lazy[p], size[p]));
				}
			}
		}
	}

	class ST_OR {
		int n;
		int[] lo, hi;
		long[] val, delta;
		ST_OR(int nn, long[] a) {
			n = nn*4+100;
			lo = new int[n]; hi = new int[n];
			val = new long[n]; delta = new long[n];
			init(1, 0, nn-1, a);
		}
		void init(int p, int left, int right, long[] a) {
			lo[p] = left; hi[p] = right;
			if(lo[p] == hi[p]) {
				val[p] = a[left];
				return;
			}
			init(2*p, left, (left+right)/2, a);
			init(2*p+1, (left+right)/2+1, right, a);
			val[p] = val[2*p]|val[2*p+1];
		}
		void update(int p, int left, int right, long mask) {
			if(right < lo[p] || left > hi[p]) return;
			if(left <= lo[p] && hi[p] <= right) {
				delta[p] |= mask;
				return;
			}
			prop(p);
			update(2*p, left, right, mask);
			update(2*p+1, left, right, mask);
			get(p);
		}
		long query(int p, int left, int right) {
			if(right < lo[p] || left > hi[p]) return 0;
			if(left <= lo[p] && hi[p] <= right) {
				return delta[p] | val[p];
			}
			prop(p);
			return query(2*p, left, right) | query(2*p+1, left, right);
		}
		void get(int p) {
			val[p] = val[2*p] | val[2*p+1] | delta[2*p] | delta[2*p+1];
		}
		void prop(int p) {
			if(delta[p] != 0) {
				delta[2*p] |= delta[p];
				delta[2*p+1] |= delta[p];
				delta[p] = 0;
				get(p);
			}
		}
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}