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

public class Main {
    void solve() {
        int n=ni(),q=ni();
        precompute();
        a=new int[n+1];
        for(int i=1;i<=n;i++) a[i]=ni();
        tree=new long[4*n+1];
        tree2=new long[4*n+1];
        lazy=new long[4*n+1];
        lazy2=new long[4*n+1];
        Arrays.fill(lazy,1);
        build(1,1,n);
        build2(1,1,n);

        while(q-->0){
            String s=ns().trim();
            if(s.equals("MULTIPLY")){
                int l=ni(),r=ni(),x=ni();
                update(1,l,r,1,n,x);
                update2(1,l,r,1,n,x);

            }else {
                int l=ni(),r=ni();
                long ans=query(1,l,r,1,n);
                long mask=query2(1,l,r,1,n);
                for(int i=0;i<62;i++){
                    if(((mask>>i)&1)==1)ans=mul(ans,mul(invIdx[i]-1,inv[invIdx[i]]));
                }
                pw.println(ans);
            }
        }

    }


    int a[];
    long tree[];
    long lazy[];
    long tree2[];
    long lazy2[];
    void build2(int id,int l,int r){
        if(l==r){
            tree2[id]=mask[a[l]];
        }else {
            int mid=(l+r)>>1;
            build2(2*id,l,mid);
            build2(2*id+1,mid+1,r);
            tree2[id]=(tree2[2*id]|tree2[2*id+1]);
        }
    }
    void push2(int id,int l,int r){
        if(lazy2[id]==0) return;
        tree2[id]|=lazy2[id];
        if(l!=r){
            lazy2[2*id]|=lazy2[id];
            lazy2[2*id+1]|=lazy2[id];

        }
        lazy2[id]=0;
    }
    void update2(int id,int x,int y,int l,int r,int num){
        push2(id,l,r);
        if(r<x || l>y) return;
        if(x<=l && r<=y){
            tree2[id]|=mask[num];
            if(l!=r){
                lazy2[2*id]|=mask[num];
                lazy2[2*id+1]|=mask[num];

            }
            return;
        }
        int mid=(l+r)>>1;
        update2(2*id,x,y,l,mid,num);
        update2(2*id+1,x,y,mid+1,r,num);
        tree2[id]=(tree2[2*id]|tree2[2*id+1]);

    }
    long query2(int id,int x,int y,int l,int r){
        push2(id,l,r);
        if(r<x || l>y) return 0;
        if(x<=l && r<=y) return tree2[id];
        int mid=(l+r)>>1;
        return (query2(2*id,x,y,l,mid)|query2(2*id+1,x,y,mid+1,r));
    }

    void build(int id,int l,int r){
        if(l==r){
            tree[id]=a[l];
        }else {
            int mid=(l+r)>>1;
            build(2*id,l,mid);
            build(2*id+1,mid+1,r);
            tree[id]=mul(tree[2*id],tree[2*id+1]);
        }
    }
    void push(int id,int l,int r){
        if(lazy[id]==1) return;
        tree[id]=mul(tree[id],modpow(lazy[id],r-l+1));

        if(l!=r){
            lazy[2*id]=mul(lazy[2*id],lazy[id]);
            lazy[2*id+1]=mul(lazy[2*id+1],lazy[id]);

        }

        lazy[id]=1;
    }
    void update(int id,int x,int y,int l,int r,int d){
        push(id,l,r);
        if(r<x || l>y) return;
        if(x<=l && r<=y){
            tree[id]=mul(tree[id],modpow(d,r-l+1));
            if(l!=r){
                lazy[2*id]=mul(lazy[2*id],d);
                lazy[2*id+1]=mul(lazy[2*id+1],d);
            }
            return;
        }
        int mid=(l+r)>>1;
        update(2*id,x,y,l,mid,d);
        update(2*id+1,x,y,mid+1,r,d);
        tree[id]=mul(tree[2*id],tree[2*id+1]);
    }
    long query(int id,int x,int y,int l,int r){
        push(id,l,r);
        if(r<x || l>y)  return 1;
        if(x<=l && r<=y){
            return tree[id];
        }
        int mid=(l+r)>>1;
        return mul(query(2*id,x,y,l,mid),query(2*id+1,x,y,mid+1,r));

    }
    int idx[],invIdx[];
    long mask[];
    long inv[];
    void precompute(){
        boolean prime[]=new boolean[301];
        mask=new long[301];
        inv=new long[301];
        idx=new int[301];
        invIdx=new int[301];
        for(int i=2;i*i<=300;i++){
            if(!prime[i]){
                for(int j=2*i;j<=300;j+=i) prime[j]=true;
            }
        }
        int id=0;

        for(int i=2;i<=300;i++){
            if(!prime[i]) {
                idx[i]=id;
                invIdx[id]=i;
                id++;
                inv[i]=modInverse(i,M);
            }
        }

        for(int i=2;i<=300;i++){
            if(!prime[i]){
                for(int j=i;j<=300;j+=i) mask[j]|=(1L<<idx[i]);
            }
        }
    }
    long add(long x,long y){
        x+=y;
        if(x>=M) x-=M;
        return x;
    }
    long sub(long x,long y){
        x-=y;
        if(x<0) x+=M;
        return x;
    }
    long mul(long x,long y){
        x*=y;
        if(x>=M) x%=M;
        return x;
    }
    long modpow(long a, long b)
    {
        long r=1;
        while(b>0)
        {
            if((b&1)>0) r=mul(r,a);
            a=mul(a,a);
            b>>=1;
        }
        return r;
    }

    long modInverse(long A, long M)
    {

        return modpow(A,M-2);
    }

    long M = (long)1e9+7;
    InputStream is;
    PrintWriter pw;
    String INPUT = "";

    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
        if (!INPUT.isEmpty()) tr(System.currentTimeMillis() - s + "ms");

    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

    private void tr(Object... o) {
        if (INPUT.length() > 0) System.out.println(Arrays.deepToString(o));
    }

}