Problem: You've got an array, consisting of n integers: a1, a2, ..., an. Your task is to quickly run the queries of two types:

  1. Assign value x to all elements from l to r inclusive. After such query the values of the elements of array al, al + 1, ..., ar become equal to x.
  2. Calculate and print sum <image>, where k doesn't exceed 5. As the value of the sum can be rather large, you should print it modulo 1000000007 (109 + 7).

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105), showing, how many numbers are in the array and the number of queries, correspondingly. The second line contains n integers: a1, a2, ..., an (0 ≤ ai ≤ 109) — the initial values of the array elements.

Then m queries follow, one per line:

  1. The assign query has the following format: "<image>", (1 ≤ l ≤ r ≤ n; 0 ≤ x ≤ 109).
  2. The query to calculate the sum has the following format: "<image>", (1 ≤ l ≤ r ≤ n; 0 ≤ k ≤ 5).



All numbers in the input are integers.

Output

For each query to calculate the sum print an integer — the required sum modulo 1000000007 (109 + 7).

Examples

Input

4 5
5 10 2 1
? 1 2 1
= 2 2 0
? 2 4 3
= 1 4 1
? 1 4 5


Output

25
43
1300


Input

3 1
1000000000 1000000000 1000000000
? 1 3 0


Output

999999986

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline int Get() {
  int res = 0, q = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') q = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return res * q;
}
const int oo = (int)2e9, mod = (int)1e9 + 7, N = (int)1e5;
int s[(N << 2) + 10][6], c[6][6], sg[(N << 2) + 10];
int mul[N + 10][6];
int n, m, ml, mr, dt;
int a[N + 10];
void Prepare() {
  ((n) = Get()), ((m) = Get());
  for (int i = (1), end = (n); i <= end; ++i) ((a[i]) = Get());
  c[0][0] = 1;
  for (int i = (1), end = (5); i <= end; ++i) {
    c[i][0] = 1;
    for (int j = (1), end = (i); j <= end; ++j)
      c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
  for (int i = (1), end = (n); i <= end; ++i) {
    int pw = 1;
    for (int j = (0), end = (5); j <= end; ++j)
      mul[i][j] = ((long long)mul[i - 1][j] + (long long)pw) % mod,
      pw = (long long)pw * (long long)i % mod;
  }
}
int Mul(int x, int k, int dt) {
  int res = s[x][k], pw = dt;
  for (int i = (1), end = (k); i <= end; ++i) {
    res = ((long long)res + (long long)c[k][i] * (long long)s[x][k - i] % mod *
                                (long long)pw % mod) %
          mod;
    pw = (long long)pw * (long long)dt % mod;
  }
  return res;
}
void Build(int l, int r, int x) {
  if (l == r) {
    sg[x] = oo;
    for (int i = (0), end = (5); i <= end; ++i) s[x][i] = a[l];
    return;
  }
  int mid = (l + r) >> 1, ls = ((x) << 1), rs = ((x) << 1 | 1);
  sg[x] = oo;
  Build(l, mid, ls), Build(mid + 1, r, rs);
  for (int i = (0), end = (5); i <= end; ++i)
    s[x][i] = ((long long)s[ls][i] + (long long)Mul(rs, i, mid - l + 1)) % mod;
}
void Perf(int x, int l, int r, int dt) {
  for (int i = (0), end = (5); i <= end; ++i)
    s[x][i] = (long long)mul[r - l + 1][i] * (long long)dt % mod;
  sg[x] = dt;
}
void Push(int x, int l, int r, int mid) {
  if (sg[x] != oo) {
    int ls = ((x) << 1), rs = ((x) << 1 | 1);
    Perf(ls, l, mid, sg[x]), Perf(rs, mid + 1, r, sg[x]);
    sg[x] = oo;
  }
}
void Change(int l, int r, int x) {
  if (l >= ml && r <= mr) {
    Perf(x, l, r, dt);
    return;
  }
  int mid = (l + r) >> 1, ls = ((x) << 1), rs = ((x) << 1 | 1);
  Push(x, l, r, mid);
  if (ml <= mid) Change(l, mid, ls);
  if (mr > mid) Change(mid + 1, r, rs);
  for (int i = (0), end = (5); i <= end; ++i)
    s[x][i] = ((long long)s[ls][i] + (long long)Mul(rs, i, mid - l + 1)) % mod;
}
int Query(int l, int r, int x) {
  if (l >= ml && r <= mr) return Mul(x, dt, l - ml);
  int mid = (l + r) >> 1;
  int res = 0;
  Push(x, l, r, mid);
  if (ml <= mid) res += Query(l, mid, ((x) << 1));
  if (mr > mid) res += Query(mid + 1, r, ((x) << 1 | 1));
  return res % mod;
}
int main() {
  Prepare();
  Build(1, n, 1);
  for (; m--;) {
    char ope[3];
    scanf("%s", ope + 1);
    ((ml) = Get()), ((mr) = Get()), ((dt) = Get());
    if (ope[1] == '=')
      Change(1, n, 1);
    else
      printf(
          "%d"
          "\n",
          Query(1, n, 1));
  }
  return 0;
}