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>
const long long MAXN = 1e5 + 5;
template <typename _T>
void read(_T &x) {
  x = 0;
  char s = getchar();
  long long f = 1;
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s - '0'), s = getchar();
  }
  x *= f;
}
template <typename _T>
void write(_T x) {
  if (x < 0) {
    putchar('-');
    x = (~x) + 1;
  }
  if (9 < x) {
    write(x / 10);
  }
  putchar(x % 10 + '0');
}
template <typename _T>
_T MAX(const _T a, const _T b) {
  return a > b ? a : b;
}
struct segmentTreeNode {
  long long l, r;
  long long cnt[10];
  long long lazy[10];
} segTree[MAXN << 2];
long long a[MAXN];
long long p[10];
long long N, Q;
void normalize(const long long now) {
  long long cnt1[10], cnt2[10];
  long long ns1[10], ns2[10];
  for (long long i = 0; i < 10; i++)
    ns1[i] = segTree[now << 1].lazy[i], ns2[i] = segTree[now << 1 | 1].lazy[i];
  for (long long i = 0; i < 10; i++)
    cnt1[i] = segTree[now << 1].cnt[i], cnt2[i] = segTree[now << 1 | 1].cnt[i];
  for (long long i = 0; i < 10; i++) {
    if (segTree[now].lazy[i] ^ i) {
      for (long long j = 0; j < 10; j++) {
        if (segTree[now << 1].lazy[j] == i) ns1[j] = segTree[now].lazy[i];
        if (segTree[now << 1 | 1].lazy[j] == i) ns2[j] = segTree[now].lazy[i];
      }
      cnt1[segTree[now].lazy[i]] += segTree[now << 1].cnt[i];
      cnt2[segTree[now].lazy[i]] += segTree[now << 1 | 1].cnt[i];
      cnt1[i] -= segTree[now << 1].cnt[i];
      cnt2[i] -= segTree[now << 1 | 1].cnt[i];
    }
    segTree[now].lazy[i] = i;
  }
  for (long long i = 0; i < 10; i++)
    segTree[now << 1].lazy[i] = ns1[i], segTree[now << 1 | 1].lazy[i] = ns2[i],
                   segTree[now << 1].cnt[i] = cnt1[i],
                   segTree[now << 1 | 1].cnt[i] = cnt2[i];
}
void upt(const long long now) {
  for (long long i = 0; i < 10; i++)
    segTree[now].cnt[i] =
        segTree[now << 1].cnt[i] + segTree[now << 1 | 1].cnt[i];
}
void build(const long long now, const long long left, const long long right) {
  segTree[now].l = left, segTree[now].r = right;
  for (long long i = 0; i < 10; i++) segTree[now].lazy[i] = i;
  if ((segTree[now].l == segTree[now].r)) {
    for (long long i = 0; i < 10 && p[i] <= a[left]; i++)
      segTree[now].cnt[(a[left] / p[i]) % 10] += p[i];
    return;
  }
  build(now << 1, left, (left + right) >> 1);
  build(now << 1 | 1, ((left + right) >> 1) + 1, right);
  upt(now);
}
void update(const long long now, const long long segL, const long long segR,
            const long long sta, const long long ed) {
  if (segR < segTree[now].l || segTree[now].r < segL) return;
  if (segL <= segTree[now].l && segTree[now].r <= segR) {
    if (sta == ed) return;
    segTree[now].cnt[ed] += segTree[now].cnt[sta], segTree[now].cnt[sta] = 0;
    long long tmp[10];
    for (long long i = 0; i < 10; i++) tmp[i] = segTree[now].lazy[i];
    for (long long i = 0; i < 10; i++)
      if (segTree[now].lazy[i] == sta) tmp[i] = ed;
    for (long long i = 0; i < 10; i++) segTree[now].lazy[i] = tmp[i];
    return;
  }
  if ((segTree[now].l == segTree[now].r)) return;
  normalize(now);
  update(now << 1, segL, segR, sta, ed);
  update(now << 1 | 1, segL, segR, sta, ed);
  upt(now);
}
long long query(const long long now, const long long segL,
                const long long segR) {
  if (segR < segTree[now].l || segTree[now].r < segL) return 0;
  if (segL <= segTree[now].l && segTree[now].r <= segR) {
    long long tmp = 0;
    for (long long i = 0; i < 10; i++) tmp += 1ll * segTree[now].cnt[i] * i;
    return tmp;
  }
  if ((segTree[now].l == segTree[now].r)) return 0;
  normalize(now);
  upt(now);
  long long tmp = query(now << 1, segL, segR);
  return tmp + query(now << 1 | 1, segL, segR);
}
signed main() {
  p[0] = 1;
  for (long long i = 1; i < 10; i++) p[i] = p[i - 1] * 10;
  read(N), read(Q);
  for (long long i = 1; i <= N; i++) {
    read(a[i]);
  }
  build(1, 1, N);
  long long opt, l, r, x, y;
  for (long long i = 1; i <= Q; i++) {
    read(opt), read(l), read(r);
    if (opt & 1) {
      read(x), read(y);
      update(1, l, r, x, y);
    } else
      write(query(1, l, r)), putchar('\n');
  }
  return 0;
}