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.
#include <bits/stdc++.h>
template <typename T>
void MACRO_VAR_Scan(T& t) {
  std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First& first, Rest&... rest) {
  std::cin >> first;
  MACRO_VAR_Scan(rest...);
}
template <typename T>
void MACRO_VEC_ROW_Init(int n, T& t) {
  t.resize(n);
}
template <typename First, typename... Rest>
void MACRO_VEC_ROW_Init(int n, First& first, Rest&... rest) {
  first.resize(n);
  MACRO_VEC_ROW_Init(n, rest...);
}
template <typename T>
void MACRO_VEC_ROW_Scan(int p, T& t) {
  std::cin >> t[p];
}
template <typename First, typename... Rest>
void MACRO_VEC_ROW_Scan(int p, First& first, Rest&... rest) {
  std::cin >> first[p];
  MACRO_VEC_ROW_Scan(p, rest...);
}
template <class T>
inline T CHMAX(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T>
inline T CHMIN(T& a, const T b) {
  return a = (a > b) ? b : a;
}
template <class T>
using V = std::vector<T>;
template <class T>
using VV = V<V<T>>;
template <typename S, typename T>
std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = std::pair<ll, ll>;
using PAIRLL = std::pair<ll, ll>;
constexpr ll INFINT = 1 << 30;
constexpr ll INFINT_LIM = (1LL << 31) - 1;
constexpr ll INFLL = 1LL << 60;
constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);
constexpr double EPS = 1e-6;
constexpr ll MOD = 1000000007;
constexpr double PI = 3.141592653589793238462643383279;
template <class T, size_t N>
void FILL(T (&a)[N], const T& val) {
  for (auto& x : a) x = val;
}
template <class ARY, size_t N, size_t M, class T>
void FILL(ARY (&a)[N][M], const T& val) {
  for (auto& b : a) FILL(b, val);
}
template <class T>
void FILL(std::vector<T>& a, const T& val) {
  for (auto& x : a) x = val;
}
template <class ARY, class T>
void FILL(std::vector<std::vector<ARY>>& a, const T& val) {
  for (auto& b : a) FILL(b, val);
}
constexpr ll N = 62;
using B = std::bitset<N>;
ll P[N] = {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};
ll iP[N];
B bit[301];
struct Node {
  ll v;
  B used;
  Node() : v(1) {}
  Node(ll v) : v(v), used(bit[v]) {}
  Node(ll v, B b) : v(v), used(b) {}
  static Node merge(const Node& l, const Node& r);
  Node& operator=(const Node& r) {
    this->v = r.v;
    this->used = r.used;
    return *this;
  }
};
ll powMod(ll n, ll p, ll mod) {
  ll res = 1;
  while (p) {
    if (p & 1) (res *= n) %= mod;
    (n *= n) %= mod;
    p >>= 1;
  }
  return res;
}
ll invMod(ll n, ll mod) { return powMod(n, mod - 2, mod); }
enum QUERY_SEG_LazySegmentTree { SUM, MAX, MIN };
enum QUERY_LAZ_LazySegmentTree { ADD, UPD };
template <class SEG, class LAZ>
class LazySegmentTree {
 private:
  std::vector<SEG> seg;
  std::vector<LAZ> laz;
  std::vector<bool> isUpdated;
  ll ARY_SIZE;
  SEG eSeg;
  LAZ eLaz;
  std::function<SEG(SEG&, SEG&)> mergeSeg;
  std::function<LAZ(LAZ&, LAZ&)> mergeLaz;
  std::function<SEG(SEG&, LAZ&, ll)> applyLaz;
  void push(ll k, ll l, ll r) {
    if (!isUpdated[k]) {
      applyLaz(seg[k], laz[k], r - l);
      if (r - l > 1) {
        mergeLaz(laz[k * 2 + 1], laz[k]);
        isUpdated[k * 2 + 1] = false;
        mergeLaz(laz[k * 2 + 2], laz[k]);
        isUpdated[k * 2 + 2] = false;
      }
      isUpdated[k] = true;
      laz[k] = eLaz;
    }
  }

 public:
  LazySegmentTree(ll n) : ARY_SIZE(1) {
    ARY_SIZE = 1;
    while (ARY_SIZE < n) ARY_SIZE *= 2;
    seg.resize(ARY_SIZE * 2 - 1);
    laz.resize(ARY_SIZE * 2 - 1);
    isUpdated.resize(ARY_SIZE * 2 - 1, true);
    eSeg = SEG(1);
    mergeSeg = [](SEG& l, SEG& r) {
      return SEG(l.v * r.v % MOD, l.used | r.used);
    };
    eLaz = 1;
    mergeLaz = [](LAZ& l, LAZ& r) {
      return l = LAZ(l.v * r.v % MOD, l.used | r.used);
    };
    applyLaz = [](SEG& l, LAZ& r, ll w) {
      return l = SEG(l.v * powMod(r.v, w, MOD) % MOD, l.used | r.used);
    };
  }
  void update(ll a, ll b, LAZ v, ll k, ll l, ll r) {
    push(k, l, r);
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      mergeLaz(laz[k], v);
      isUpdated[k] = false;
      push(k, l, r);
    } else {
      update(a, b, v, k * 2 + 1, l, (l + r) / 2);
      update(a, b, v, k * 2 + 2, (l + r) / 2, r);
      seg[k] = mergeSeg(seg[k * 2 + 1], seg[k * 2 + 2]);
    }
  }
  void update(ll l, ll r, LAZ v) { update(l, r, v, 0, 0, ARY_SIZE); }
  SEG query(ll a, ll b, ll k, ll l, ll r) {
    push(k, l, r);
    if (r <= a || b <= l) return eSeg;
    if (a <= l && r <= b) return seg[k];
    SEG vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    SEG vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return mergeSeg(vl, vr);
  }
  SEG query(ll l, ll r) { return query(l, r, 0, 0, ARY_SIZE); }
};
using LST = LazySegmentTree<ll, ll>;
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ;
  for (ll i = (1); i < (301); ++i)
    for (ll j = 0; j < ll(N); ++j) {
      bit[i][j] = i % P[j] == 0;
    }
  for (ll i = 0; i < ll(N); ++i) iP[i] = invMod(P[i], MOD);
  ll n, Q;
  MACRO_VAR_Scan(n, Q);
  ;
  std::vector<ll> a(n);
  for (auto& i : a) std::cin >> i;
  ;
  LazySegmentTree<Node, Node> st(n);
  for (ll i = 0; i < ll(n); ++i) st.update(i, i + 1, Node(a[i]));
  for (ll _ = 0; _ < ll(Q); ++_) {
    std::string s;
    MACRO_VAR_Scan(s);
    ;
    if (s[0] == 'T') {
      ll l, r;
      MACRO_VAR_Scan(l, r);
      ;
      --l;
      auto res = st.query(l, r);
      ll t = res.v;
      for (ll i = 0; i < ll(N); ++i)
        if (res.used[i]) {
          (t *= (P[i] - 1) * iP[i] % MOD) %= MOD;
        }
      std::cout << (t);
      std::cout << "\n";
      ;
    } else {
      ll l, r, x;
      MACRO_VAR_Scan(l, r, x);
      ;
      --l;
      st.update(l, r, Node(x));
    }
  }
  return 0;
}
