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.
// upsolve with rainboy
import java.io.*;
import java.util.*;

public class CF1114F {
	static final int A = 300, K = 62, MD = 1000000007;
	static long[] bb = new long[1 + A];
	static long[] pp = new long[K];
	static long power(long a, int k) {
		if (k == 0)
			return 1;
		long p = power(a, k / 2);
		p = p * p % MD;
		if (k % 2 == 1)
			p = p * a % MD;
		return p;
	}
	static void init() {
		boolean[] composite = new boolean[1 + A];
		int k = 0;
		for (int a = 2; a <= A; a++) {
			if (composite[a])
				continue;
			pp[k] = (a - 1) * power(a, MD - 2) % MD;
			for (int b = a; b <= A; b += a) {
				composite[b] = true;
				bb[b] |= 1L << k;
			}
			k++;
		}
	}
	static int[] aa;
	static long[] t1, l1, t2, l2;
	static void build(int k, int l, int r) {
		l1[k] = 1;
		if (r - l == 1) {
			t1[k] = aa[l];
			t2[k] = bb[aa[l]];
			return;
		}
		int m = (l + r) / 2;
		int k1 = k * 2 + 1, k2 = k * 2 + 2;
		build(k1, l, m);
		build(k2, m, r);
		t1[k] = t1[k1] * t1[k2] % MD;
		t2[k] = t2[k1] | t2[k2];
	}
	static void push(int k, int l, int r) {
		int m = (l + r) / 2;
		int k1 = k * 2 + 1, k2 = k * 2 + 2;
		if (l2[k] != 0) {
			long x_ = l1[k];
			t1[k1] = t1[k1] * power(x_, m - l) % MD; l1[k1] = l1[k1] * x_ % MD;
			t1[k2] = t1[k2] * power(x_, r - m) % MD; l1[k2] = l1[k2] * x_ % MD;
			l1[k] = 1;
			long b = l2[k];
			t2[k1] |= b; l2[k1] |= b;
			t2[k2] |= b; l2[k2] |= b;
			l2[k] = 0;
		}
	}
	static void update(int k, int l, int r, int ql, int qr, int x) {
		if (qr <= l || r <= ql)
			return;
		if (ql <= l && r <= qr) {
			t1[k] = t1[k] * power(x, r - l) % MD; l1[k] = l1[k] * x % MD;
			t2[k] |= bb[x]; l2[k] |= bb[x];
			return;
		}
		int m = (l + r) / 2;
		int k1 = k * 2 + 1, k2 = k * 2 + 2;
		push(k, l, r);
		update(k1, l, m, ql, qr, x);
		update(k2, m, r, ql, qr, x);
		t1[k] = t1[k1] * t1[k2] % MD;
		t2[k] = t2[k1] | t2[k2];
	}
	static long a1, a2;
	static void query(int k, int l, int r, int ql, int qr) {
		if (qr <= l || r <= ql)
			return;
		if (ql <= l && r <= qr) {
			a1 = a1 * t1[k] % MD;
			a2 |= t2[k];
			return;
		}
		int m = (l + r) / 2;
		int k1 = k * 2 + 1, k2 = k * 2 + 2;
		push(k, l, r);
		query(k1, l, m, ql, qr);
		query(k2, m, r, ql, qr);
	}
	public static void main(String[] args) throws IOException {
		init();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int q = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = Integer.parseInt(st.nextToken());
		int n_ = 1;
		while (n_ < n)
			n_ *= 2;
		n_ *= 2;
		t1 = new long[n_];
		l1 = new long[n_];
		t2 = new long[n_];
		l2 = new long[n_];
		build(0, 0, n);
		while (q-- > 0) {
			st = new StringTokenizer(br.readLine());
			String s = st.nextToken();
			int l = Integer.parseInt(st.nextToken()) - 1;
			int r = Integer.parseInt(st.nextToken());
			if (s.charAt(0) == 'M') {
				int x = Integer.parseInt(st.nextToken());
				update(0, 0, n, l, r, x);
			} else {
				a1 = 1; a2 = 0;
				query(0, 0, n, l, r);
				for (int i = 0; i < K; i++)
					if ((a2 & 1L << i) != 0)
						a1 = a1 * pp[i] % MD;
				pw.println(a1);
			}
		}
		pw.close();
	}
}
