#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;
}
