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;
int tsum[4 * 210000][6], tr[4 * 210000], c[6][6], a[210000], n, m, l, r, x, ans;
long long sum[210000][6];
char ch;
int summ(int l, int r, int k) {
  if (!k) return (r - l + 1);
  if (!l) return 0;
  return (sum[r][k] - sum[l - 1][k] + 1000000007) % 1000000007;
}
void renew(int l, int r, int no) {
  if (tr[no] < 0) return;
  for (int i = 0; i <= 5; ++i)
    tsum[no][i] = (long long)tr[no] * summ(l, r, i) % 1000000007;
  tr[2 * no] = tr[no];
  tr[2 * no + 1] = tr[no];
  tr[no] = -1;
}
void update(int no) {
  for (int i = 0; i <= 5; ++i)
    tsum[no][i] = (tsum[2 * no][i] + tsum[2 * no + 1][i]) % 1000000007;
}
int getsum(int l, int r, int ll, int rr, int k, int no) {
  if (l > rr || ll > r) return 0;
  renew(l, r, no);
  if (ll <= l && r <= rr) return tsum[no][k];
  return (getsum(l, (l + r) >> 1, ll, rr, k, 2 * no) +
          getsum(((l + r) >> 1) + 1, r, ll, rr, k, 2 * no + 1)) %
         1000000007;
}
void rev(int l, int r, int ll, int rr, int x, int no) {
  renew(l, r, no);
  if (l > rr || ll > r) return;
  if (ll <= l && r <= rr) {
    for (int i = 0; i <= 5; ++i)
      tsum[no][i] = (long long)x * summ(l, r, i) % 1000000007;
    tr[2 * no] = x;
    tr[2 * no + 1] = x;
    return;
  }
  rev(l, (l + r) >> 1, ll, rr, x, 2 * no);
  rev(((l + r) >> 1) + 1, r, ll, rr, x, 2 * no + 1);
  update(no);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i)
    for (long long j = 0, k = 1; j <= 5; ++j, k *= i, k %= 1000000007)
      sum[i][j] = (sum[i - 1][j] + k) % 1000000007;
  for (int i = 0; i <= 5; ++i) c[i][0] = 1;
  for (int i = 1; i <= 5; ++i)
    for (int j = 1; j <= i; ++j) c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
  memset(tr, 128, sizeof(tr));
  for (int i = 1; i <= n; ++i) rev(1, n, i, i, a[i], 1);
  while (m--) {
    cin >> ch >> l >> r >> x;
    if (ch == '?') {
      ans = 0;
      for (int i = 0; i <= x; ++i) {
        long long res = getsum(1, n, l, r, i, 1);
        res *= c[x][i];
        res %= 1000000007;
        res *= summ(l - 1, l - 1, x - i), res %= 1000000007;
        if ((x - i) & 1) res *= -1;
        res = (res + 1000000007) % 1000000007;
        ans += res;
        ans %= 1000000007;
      }
      cout << ans << endl;
    } else
      rev(1, n, l, r, x, 1);
  }
  return 0;
}