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.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC)throws Exception {
        int n = ni(), q = ni(), mx = 300;
        int[] spf = new int[1+mx];
        int[] pr = new int[mx];int cnt = 0;
        long[] inv = new long[mx];
        spf[0] = spf[1] = 0;
        for(int i = 2; i<= mx; i++)
            if(spf[i] == 0){
                spf[i] = i;
                pr[cnt] = i;
                inv[cnt++] = pow(i, MOD-2);
                for(int j = i; j<= mx; j += i)
                    if(spf[j] == 0)spf[j] = i;
            }
        int[] a = new int[n];
        ORTree or = new ORTree(n);
        for(int i = 0; i< n; i++){
            a[i] = ni();
            int x = a[i];
            long mask = 0;
            for(int j = 0; j< cnt; j++){
                if(x%pr[j] == 0){
                    mask |= 1L<<j;
                    while(x%pr[j] == 0)x /= pr[j];
                }
            }
            or.u(i, i, mask);
        }
        SegTree t = new SegTree(a);

        while(q-->0){
            if(n().charAt(0) == 'M'){
                int l = ni()-1, r = ni()-1, x = ni();
                t.u(l, r, x);
                long mask = 0;
                for(int i = 0; i< cnt; i++){
                    if(x%pr[i] == 0){
                        mask |= 1L<<i;
                        while(x%pr[i] == 0)x /= pr[i];
                    }
                }
                or.u(l, r, mask);
            }else{
                int l = ni()-1, r = ni()-1;
                long ans = t.p(l, r);
                long mask = or.p(l, r);
                for(int i = 0; i< cnt; i++)
                    if(((mask>>i)&1)==1)
                        ans = (ans * (pr[i] - 1)%MOD * inv[i]) % MOD;
                pn(ans);
            }
        }
    }
    class ORTree{
        int m = 1;
        long[] t, lazy;
        public ORTree(int n){
            while(m<n)m<<=1;
            t = new long[m<<1];
            lazy = new long[m<<1];
        }
        void push(int ll, int rr, int i){
            t[i] |= lazy[i];
            if(ll != rr){
                lazy[i<<1] |= lazy[i];
                lazy[i<<1|1] |= lazy[i];
            }
            lazy[i] = 0;
        }
        void u(int l, int r, long x){u(l, r, 0, m-1, 1, x);}
        long p(int l, int r){return p(l, r, 0, m-1, 1);}
        void u(int l, int r, int ll, int rr, int i, long x){
            push(ll, rr, i);
            if(l == ll && r == rr){
                lazy[i] = x;
                push(ll, rr, i);
                return;
            }
            int mid = (ll+rr)>>1;
            if(r <= mid){
                u(l, r, ll, mid, i<<1, x);
                push(mid+1, rr, i<<1|1);
            }else if(l > mid){
                push(ll, mid, i<<1);
                u(l, r, mid+1, rr, i<<1|1, x);
            }else{
                u(l, mid, ll, mid, i<<1, x);
                u(mid+1, r, mid+1, rr, i<<1|1, x);
            }
            t[i] = (t[i<<1]|t[i<<1|1]);
        }
        long p(int l, int r, int ll, int rr, int i){
            push(ll, rr, i);
            if(l == ll && r == rr)return t[i];
            int mid = (ll+rr)>>1;
            if(r <= mid)return p(l, r, ll, mid, i<<1);
            else if(l > mid)return p(l, r, mid+1, rr, i<<1|1);
            else return (p(l, mid, ll, mid, i<<1)|p(mid+1, r, mid+1, rr, i<<1|1));
        }
    }
    long MOD = (long)1e9+7;
    long pow(long a, long p){
        long o = 1;
        for(;p>0;p>>=1){
            if((p&1)==1)o = (o*a)%MOD;
            a = (a*a)%MOD;
        }
        return o;
    }
    class SegTree{
        int m = 1;
        long[] t, lazy;
        public SegTree(int[] a){
            while(m<a.length)m<<=1;
            t = new long[m<<1];
            lazy = new long[m<<1];
            Arrays.fill(t, 1);
            Arrays.fill(lazy, 1);
            for(int i = 0; i< a.length; i++)t[i+m] = a[i];
            for(int i = m-1; i> 0; i--)t[i] = (t[i<<1]*t[i<<1|1])%MOD;
        }
        void push(int ll, int rr, int i){
            if(lazy[i] == 1)return;
            t[i] = (t[i]*pow(lazy[i], rr-ll+1))%MOD;
            if(ll != rr){
                lazy[i<<1] = (lazy[i<<1]*lazy[i])%MOD;
                lazy[i<<1|1] = (lazy[i<<1|1]*lazy[i])%MOD;
            }
            lazy[i] = 1;
        }
        void u(int l, int r, int x){u(l, r, 0, m-1, 1, x);}
        long p(int l, int r){return p(l, r, 0, m-1, 1);}
        void u(int l, int r, int ll, int rr, int i, int x){
            push(ll, rr, i);
            if(l == ll && r == rr){
                lazy[i] = x;
                push(ll, rr, i);
                return;
            }
            int mid = (ll+rr)>>1;
            if(r <= mid){
                u(l, r, ll, mid, i<<1, x);
                push(mid+1, rr, i<<1|1);
            }else if(l > mid){
                push(ll, mid, i<<1);
                u(l, r, mid+1, rr, i<<1|1, x);
            }else{
                u(l, mid, ll, mid, i<<1, x);
                u(mid+1, r, mid+1, rr, i<<1|1, x);
            }
            t[i] = (t[i<<1]*t[i<<1|1])%MOD;
        }
        long p(int l, int r, int ll, int rr, int i){
            push(ll, rr, i);
            if(l == ll && r == rr)return t[i];
            int mid = (ll+rr)>>1;
            if(r <= mid)return p(l, r, ll, mid, i<<1);
            else if(l > mid)return p(l, r, mid+1, rr, i<<1|1);
            else return (p(l, mid, ll, mid, i<<1)*p(mid+1, r, mid+1, rr, i<<1|1))%MOD;
        }
    }
    int[][] makeU(int n, int[] from, int[] to){
        int[] cnt = new int[n];
        int[][] g = new int[n][];
        for(int i:from)cnt[i]++;for(int i:to)cnt[i]++;
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< n-1; i++){
            g[from[i]][--cnt[from[i]]] = to[i];
            g[to[i]][--cnt[to[i]]] = from[i];
        }
        return g;
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    long IINF = (long)1e15;
    final int INF = (int)1e9+2, MX = (int)2e6+5;
//    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-7;
    static boolean multipleTC = false, memory = false, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        long ct = System.currentTimeMillis();
        if(fileIO){
            in = new FastReader("");
            out = new PrintWriter("");
        }else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();
        for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
        System.err.println(System.currentTimeMillis()-ct);
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}