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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.Reader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyInput in = new MyInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FPleaseAnotherQueriesOnArray solver = new FPleaseAnotherQueriesOnArray();
        solver.solve(1, in, out);
        out.close();
    }

    static class FPleaseAnotherQueriesOnArray {
        static int mod = (int) 1e9 + 7;

        public void solve(int testNumber, MyInput in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            long[] inv = new long[301];
            int[] ps = primesByEratosthenes(300);
            Data[] data = new Data[301];
            for (int i = 1; i <= 300; i++) {
                long bit = 0;
                for (int j = 0; j < ps.length; j++) {
                    if (i % ps[j] == 0) {
                        bit |= 1L << j;
                    }
                }
                data[i] = new Data(i, bit);
                inv[i] = powmod(i, mod - 2, mod);
            }
            Data[] initVal = new Data[n];
            for (int i = 0; i < n; i++) {
                initVal[i] = data[in.nextInt()];
            }
            LazySegmentTree<Data> seg = new LazySegmentTree<>(initVal);
            for (int i = 0; i < q; i++) {
                char t = in.nextChars()[0];
                int l = in.nextInt() - 1;
                int r = in.nextInt();
                if (t == 'T') {
                    Data d = seg.get(l, r);
                    long ans = d.val;
                    for (int j = 0; j < ps.length; j++) {
                        if ((d.bit >>> j & 1) == 1) {
                            ans = ans * inv[ps[j]] % mod * (ps[j] - 1) % mod;
                        }
                    }
                    out.println(ans);
                } else {
                    seg.add(l, r, data[in.nextInt()]);
                }
            }
        }

        private static boolean[] eratosthenes(int n) {
            final boolean[] p = new boolean[n + 1];
            Arrays.fill(p, true);
            p[0] = p[1] = false;
            for (int i = 2; i * i <= n; i++) {
                if (p[i]) {
                    for (int j = i * i; j <= n; j += i) {
                        p[j] = false;
                    }
                }
            }
            return p;
        }

        private static int[] primesByEratosthenes(int n) {
            final boolean[] p = eratosthenes(n);

            int cnt = 0;
            for (int i = 2; i <= n; i++) {
                if (p[i]) {
                    cnt++;
                }
            }

            int[] res = new int[cnt];
            for (int i = 2, j = 0; i <= n; i++) {
                if (p[i]) {
                    res[j++] = i;
                }
            }

            return res;
        }

        static long powmod(long n, long r, int m) {
            long res = 1;
            for (; r != 0; r >>>= 1, n = n * n % m) {
                if ((r & 1) == 1) {
                    res = res * n;
                    if (res >= m) {
                        res %= m;
                    }
                }
            }
            return res;
        }

        class Data implements FPleaseAnotherQueriesOnArray.Monoid<Data> {
            long val;
            long bit;

            public Data(long l, long l1) {
                val = l;
                bit = l1;
            }

            public Data zero() {
                return new Data(1, 0);
            }

            public Data merge(Data rhs) {
                return new Data(val * rhs.val % mod, bit | rhs.bit);
            }

            public Data merge(Data rhs, int interval) {
                return new Data(val * powmod(rhs.val, interval, mod) % mod, bit | rhs.bit);
            }

        }

        interface Monoid<T> {
            T zero();

            default T merge(T rhs) {
                return merge(rhs, 1);
            }

            T merge(T rhs, int interval);

        }

        class LazySegmentTree<T extends FPleaseAnotherQueriesOnArray.Monoid<T>> {
            private final T zero;
            final int n;
            final boolean[] lazy;
            final List<T> seg;
            final List<T> add;

            public LazySegmentTree(T[] val) {
                zero = val[0].zero();
                n = Integer.highestOneBit(val.length) << 1;
                seg = new ArrayList<>(n << 1);
                add = new ArrayList<>(n << 1);
                lazy = new boolean[n << 1];
                for (int i = 0; i < lazy.length; i++) {
                    seg.add(null);
                    add.add(zero);
                }
                for (int i = 2 * n - 1; i >= 0; i--) {
                    final int j = i - this.n + 1;
                    if (j >= 0) {
                        seg.set(i, j < val.length ? val[j] : zero);
                    } else {
                        seg.set(i, seg.get(2 * i + 1).merge(seg.get(2 * i + 2)));
                    }
                }
            }

            private void propagate(int curL, int curR, int k) {
                if (lazy[k]) {
                    final int curM = (curL + curR) / 2;
                    add(curL, curR, 2 * k + 1, add.get(k), curL, curM);
                    add(curL, curR, 2 * k + 2, add.get(k), curM, curR);
                    lazy[k] = false;
                    add.set(k, zero);
                }
            }

            T get(int l, int r) {
                return get(l, r, 0, 0, n);
            }

            T get(int l, int r, int k, int curL, int curR) {
                if (curR <= l || curL >= r) return zero;
                if (l <= curL && curR <= r) {
                    return seg.get(k);
                }
                propagate(curL, curR, k);
                final int curM = (curL + curR) / 2;
                return get(l, r, 2 * k + 1, curL, curM).merge(get(l, r, 2 * k + 2, curM, curR));
            }

            void add(int l, int r, T v) {
                add(l, r, 0, v, 0, n);
            }

            void add(int l, int r, int k, T v, int curL, int curR) {
                if (curR <= l || curL >= r) return;
                if (l <= curL && curR <= r) {
                    seg.set(k, seg.get(k).merge(v, curR - curL));
                    add.set(k, add.get(k).merge(v));
                    lazy[k] = true;
                    return;
                }
                final int curM = (curL + curR) / 2;
                propagate(curL, curR, k);
                add(l, r, 2 * k + 1, v, curL, curM);
                add(l, r, 2 * k + 2, v, curM, curR);
                seg.set(k, seg.get(2 * k + 1).merge(seg.get(2 * k + 2)));
            }

        }

    }

    static class MyInput {
        private final BufferedReader in;
        private static int pos;
        private static int readLen;
        private static final char[] buffer = new char[1024 * 8];
        private static char[] str = new char[500 * 8 * 2];
        private static boolean[] isDigit = new boolean[256];
        private static boolean[] isSpace = new boolean[256];
        private static boolean[] isLineSep = new boolean[256];

        static {
            for (int i = 0; i < 10; i++) {
                isDigit['0' + i] = true;
            }
            isDigit['-'] = true;
            isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
            isLineSep['\r'] = isLineSep['\n'] = true;
        }

        public MyInput(InputStream is) {
            in = new BufferedReader(new InputStreamReader(is));
        }

        public int read() {
            if (pos >= readLen) {
                pos = 0;
                try {
                    readLen = in.read(buffer);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (readLen <= 0) {
                    throw new MyInput.EndOfFileRuntimeException();
                }
            }
            return buffer[pos++];
        }

        public int nextInt() {
            int len = 0;
            str[len++] = nextChar();
            len = reads(len, isSpace);
            int i = 0;
            int ret = 0;
            if (str[0] == '-') {
                i = 1;
            }
            for (; i < len; i++) ret = ret * 10 + str[i] - '0';
            if (str[0] == '-') {
                ret = -ret;
            }
            return ret;
        }

        public char nextChar() {
            while (true) {
                final int c = read();
                if (!isSpace[c]) {
                    return (char) c;
                }
            }
        }

        int reads(int len, boolean[] accept) {
            try {
                while (true) {
                    final int c = read();
                    if (accept[c]) {
                        break;
                    }
                    if (str.length == len) {
                        char[] rep = new char[str.length * 3 / 2];
                        System.arraycopy(str, 0, rep, 0, str.length);
                        str = rep;
                    }
                    str[len++] = (char) c;
                }
            } catch (MyInput.EndOfFileRuntimeException e) {
            }
            return len;
        }

        public char[] nextChars() {
            int len = 0;
            str[len++] = nextChar();
            len = reads(len, isSpace);
            return Arrays.copyOf(str, len);
        }

        static class EndOfFileRuntimeException extends RuntimeException {
        }

    }
}

