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.util.*;
import java.io.*;

public class Main {
    static int[] prime = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
            71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,
            167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
            269, 271, 277, 281, 283, 293};
    static final int MOD = (int) (1E9 + 7);
    static long[] inv = new long[305];
    static long[] mask = new long[305];
    static int[] a;
    static int n, q;
    public static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;
        InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }
        String next() {
            while (tokenizer == null || !tokenizer.hasMoreElements()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
                catch(IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = " ";
            try {
                str = reader.readLine();
            }
            catch(IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    static class Node {
        long prod;
        long mask;
        long lazy1;
        long lazy2;
        Node() {
            prod = lazy1 = 1;
            mask = lazy2 = 0;
        }
    }
    static Node[] node;
    static long power(long a, long b) {
        if (b == 0) return 1;
        if (b == 1) return a % MOD;
        long p = power(a, b >> 1);
        if (b % 2 == 1) return a * p % MOD * p % MOD;
        else return p * p % MOD;
    }
    static void build(int k, int l, int r) {
        if (l == r) {
            node[k].prod = a[r];
            node[k].mask = mask[a[r]];
            return;
        }
        int m = l + r >> 1;
        build(k << 1, l, m);
        build(k << 1 | 1, m + 1, r);
        node[k].prod = node[k << 1].prod * node[k << 1 | 1].prod % MOD;
        node[k].mask = node[k << 1].mask | node[k << 1 | 1].mask;
    }
    static void down(int k, int l, int r) {
        int m = l + r >> 1;
        long temp = node[k].lazy1;
        if (temp != 1) {
            node[k << 1].prod *= power(temp, m - l + 1);
            node[k << 1].prod %= MOD;
            node[k << 1].lazy1 *= temp;
            node[k << 1].lazy1 %= MOD;
            node[k << 1 | 1].prod *= power(temp, r - m);
            node[k << 1 | 1].prod %= MOD;
            node[k << 1 | 1].lazy1 *= temp;
            node[k << 1 | 1].lazy1 %= MOD;
            node[k].lazy1 = 1;
        }
        temp = node[k].lazy2;
        if (temp > 0) {
            node[k << 1].mask |= temp;
            node[k << 1].lazy2 |= temp;
            node[k << 1 | 1].mask |= temp;
            node[k << 1 | 1].lazy2 |= temp;
            node[k].lazy2 = 0;
        }
    }
    static void update(int k, int l, int r, int u, int v, int val) {
        if (v < l || r < u) return;
        if (u <= l && r <= v) {
            node[k].prod *= power(val, r - l + 1);
            node[k].prod %= MOD;
            node[k].lazy1 *= val;
            node[k].lazy1 %= MOD;
            node[k].mask |= mask[val];
            node[k].lazy2 |= mask[val];
            return;
        }
        down(k, l, r);
        int m = l + r >> 1;
        update(k << 1, l, m, u, v, val);
        update(k << 1 | 1, m + 1, r, u, v, val);
        node[k].prod = node[k << 1].prod * node[k << 1 | 1].prod % MOD;
        node[k].mask = node[k << 1].mask | node[k << 1 | 1].mask;
    }
    static long getProduct(int k, int l, int r, int u, int v) {
        if (v < l || r < u) return 1;
        if (u <= l && r <= v) return node[k].prod;
        down(k, l, r);
        int m = l + r >> 1;
        return getProduct(k << 1, l, m, u, v) * getProduct(k << 1 | 1, m + 1, r, u, v) % MOD;
    }
    static long getMask(int k, int l, int r, int u, int v) {
        if (v < l || r < u) return 0;
        if (u <= l && r <= v) return node[k].mask;
        down(k, l, r);
        int m = l + r >> 1;
        return getMask(k << 1, l, m, u, v) | getMask(k << 1 | 1, m + 1, r, u, v);
    }
    public static void main(String[] args) {
        //InputReader in = new InputReader();
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        q = in.nextInt();
        a = new int[n + 5];
        node = new Node[16 * n];
        for (int i = 1 ; i <= 4 * n + 5; i++) node[i] = new Node();
        for (int i = 1 ; i <= n; i++) {
            a[i] = in.nextInt();
        }
        in.nextLine();
        for (int i = 2 ; i <= 300; i++) {
            for (int j = 0 ; j < 62; j++) {
                if (i % prime[j] == 0) {
                    mask[i] |= (long) 1 << j;
                }
            }
        }
        for (int i = 0 ; i < 62; i++) {
            inv[i] = power(prime[i], MOD - 2);
        }
        build(1, 1, n);
        while (q-- > 0) {
            String type = in.nextLine();
            StringTokenizer tokenizer = new StringTokenizer(type, " ");
            if (type.charAt(0) == 'M') {
                int cnt = 0;
                int l = 0;
                int r = 0;
                int x = 0;
                while (tokenizer.hasMoreTokens()) {
                    cnt++;
                    if (cnt == 1) tokenizer.nextToken();
                    if (cnt == 2) l = Integer.parseInt(tokenizer.nextToken());
                    if (cnt == 3) r = Integer.parseInt(tokenizer.nextToken());
                    if (cnt == 4) x = Integer.parseInt(tokenizer.nextToken());
                }
                if (x == 1) continue;
                update(1, 1, n, l, r, x);
            }
            else {
                int l = 0;
                int r = 0;
                int cnt = 0;
                while (tokenizer.hasMoreTokens()) {
                    cnt++;
                    if (cnt == 1) tokenizer.nextToken();
                    if (cnt == 2) l = Integer.parseInt(tokenizer.nextToken());
                    if (cnt == 3) r = Integer.parseInt(tokenizer.nextToken());
                }
                long res1 = getProduct(1, 1, n, l, r);
                long res2 = getMask(1, 1, n, l, r);
                for (int i = 0 ; i < 62; i++) {
                    if (((res2 >> i) & 1) == 1) {
                        res1 *= (prime[i] - 1) * inv[i] % MOD;
                        res1 %= MOD;
                    }
                }
                System.out.println(res1);
            }
        }
    }
}