Problem: Bankopolis, the city you already know, finally got a new bank opened! Unfortunately, its security system is not yet working fine... Meanwhile hacker Leha arrived in Bankopolis and decided to test the system!

Bank has n cells for clients' money. A sequence from n numbers a1, a2, ..., an describes the amount of money each client has. Leha wants to make requests to the database of the bank, finding out the total amount of money on some subsegments of the sequence and changing values of the sequence on some subsegments. Using a bug in the system, Leha can requests two types of queries to the database:

  * 1 l r x y denoting that Leha changes each digit x to digit y in each element of sequence ai, for which l ≤ i ≤ r is holds. For example, if we change in number 11984381 digit 8 to 4, we get 11944341. It's worth noting that Leha, in order to stay in the shadow, never changes digits in the database to 0, i.e. y ≠ 0. 
  * 2 l r denoting that Leha asks to calculate and print the sum of such elements of sequence ai, for which l ≤ i ≤ r holds. 



As Leha is a white-hat hacker, he don't want to test this vulnerability on a real database. You are to write a similar database for Leha to test.

Input

The first line of input contains two integers n and q (1 ≤ n ≤ 105, 1 ≤ q ≤ 105) denoting amount of cells in the bank and total amount of queries respectively. 

The following line contains n integers a1, a2, ..., an (1 ≤ ai < 109) denoting the amount of money in each cell initially. These integers do not contain leading zeros.

Each of the following q lines has one of the formats:

  * 1 l r x y (1 ≤ l ≤ r ≤ n, 0 ≤ x ≤ 9, 1 ≤ y ≤ 9), denoting Leha asks to change each digit x on digit y for each element ai of the sequence for which l ≤ i ≤ r holds; 
  * 2 l r (1 ≤ l ≤ r ≤ n), denoting you have to calculate and print the sum of elements ai for which l ≤ i ≤ r holds. 

Output

For each second type query print a single number denoting the required sum.

Examples

Input

5 5
38 43 4 12 70
1 1 3 4 8
2 2 4
1 4 5 0 8
1 2 5 8 7
2 1 5


Output

103
207


Input

5 5
25 36 39 40 899
1 1 3 2 7
2 1 2
1 3 5 9 1
1 4 4 0 9
2 1 5


Output

111
1002

Note

Let's look at the example testcase.

Initially the sequence is [38, 43, 4, 12, 70]. 

After the first change each digit equal to 4 becomes 8 for each element with index in interval [1; 3]. Thus, the new sequence is [38, 83, 8, 12, 70].

The answer for the first sum's query is the sum in the interval [2; 4], which equal 83 + 8 + 12 = 103, so the answer to this query is 103.

The sequence becomes [38, 83, 8, 12, 78] after the second change and [38, 73, 7, 12, 77] after the third.

The answer for the second sum's query is 38 + 73 + 7 + 12 + 77 = 207.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
char P[(1 << 17) * 2][10];
int p[9][(1 << 17) * 2][10], I, z[10], F[20][10];
bitset<(1 << 17) * 2> C;
struct sX {
  int N;
  void ini(int n) {
    N = 1 << (int(log2(n) - (1e-10)) + 1), (memset(p, 0, sizeof(p)));
    if (!I)
      for (int i(0); i < N << 1; i++) iota(P[i], P[i] + 10, 0);
  }
  void nm(int b, int v) { nm(b, v, 1, 0, N - 1); }
  void nm(int b, int v, int u, int B, int E) {
    if (B > b || E < b) return;
    if (E == B) {
      ++p[I][u][v];
      return;
    }
    nm(b, v, u << 1, B, (B + E) >> 1), nm(b, v, u << 1 | 1, (B + E) / 2 + 1, E);
    ++p[I][u][v];
  }
  void ap(int u, char *w) {
    if (!I) {
      if (C[u])
        for (int i(0); i < 10; i++) P[u][i] = w[(int)P[u][i]];
      else
        memcpy(P[u], w, sizeof(P[u]));
    }
    C[u] = 1;
  }
  void st(int b, int e, int f, int t) { st(b, e, f, t, 1, 0, N - 1); }
  void AD(int u, int *f) {
    for (int i(0); i < 10; i++) f[(int)P[u][i]] += p[I][u][i];
  }
  void st(int b, int e, int f, int t, int u, int B, int E) {
    if (B > e || E < b) return;
    if (b <= B && e >= E) {
      if (I) return;
      if (C[u]) {
        for (int i(0); i < 10; i++)
          if (P[u][i] == f) P[u][i] = t;
      } else
        P[u][f] = t, C[u] = 1;
      return;
    }
    if (C[u])
      ap(u << 1, P[u]), ap(u << 1 | 1, P[u]), iota(P[u], P[u] + 10, 0),
          C[u] = 0;
    st(b, e, f, t, u << 1, B, (B + E) >> 1),
        st(b, e, f, t, u << 1 | 1, (B + E) / 2 + 1, E);
    (memset(p[I][u], 0, sizeof(p[I][u]))), AD(u << 1, p[I][u]),
        AD(u << 1 | 1, p[I][u]);
  }
  void gt(int b, int e, int *f) { gt(b, e, f, 1, 0, N - 1, 0); }
  void gt(int b, int e, int *f, int u, int B, int E, int d) {
    if (B > e || E < b) return;
    if (b <= B && e >= E) return AD(u, f);
    if (!C[u] && b > (B + E) >> 1)
      return gt(b, e, f, u << 1 | 1, (B + E) / 2 + 1, E, d + 1);
    if (!C[u] && e <= (B + E) >> 1)
      return gt(b, e, f, u << 1, B, (B + E) >> 1, d + 1);
    (memset(F[d], 0, sizeof(F[d])));
    gt(b, e, F[d], u << 1, B, (B + E) >> 1, d + 1),
        gt(b, e, F[d], u << 1 | 1, (B + E) / 2 + 1, E, d + 1);
    for (int i(0); i < 10; i++) f[(int)P[u][i]] += F[d][i];
  }
} T[9];
char s[32];
int N, Q, L, a, b, c, d, e, f, H[10];
long long S, t;
int main(void) {
  scanf("%d%d", &N, &Q);
  for (int i(0); i < 9; i++) I = i, T[i].ini(N);
  for (int i(0); i < N; i++) {
    scanf("%s", s), L = strlen(s);
    for (int j(0); j < L; j++) I = L - j - 1, T[L - j - 1].nm(i, s[j] - 48);
  }
  for (int i(0); i < Q; i++) {
    scanf("%d%d%d", &a, &b, &c), --b, --c;
    if (a == 1) {
      scanf("%d%d", &d, &e);
      if (d == e) continue;
      for (int i(0); i < 9; i++) I = i, T[i].st(b, c, d, e);
    } else {
      S = 0, t = 1;
      for (int i(0); i < 9; i++) {
        I = i, (memset(H, 0, sizeof(H))), T[i].gt(b, c, H);
        for (int j(0); j < 10; j++) S += H[j] * t * j;
        t *= 10;
      }
      printf("%lld\n", S);
    }
  }
  return 0;
}