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>
#pragma GCC optimize("O3")
using namespace std;
struct Node {
  long long sum[10];
  int nx[10];
};
long long ch[10];
int pi[10];
struct SegTree {
  Node T[500000];
  int N;
  void Init(int n, long long a[]) {
    N = 1 << int(log2(n - 1) + 1);
    for (int i = 0; i < 500000; i++) {
      for (int j = 0; j < 10; j++) T[i].sum[j] = 0, T[i].nx[j] = j;
    }
    int p = 0;
    long long rz;
    long long dl;
    for (int j = N; j < N + n; j++) {
      dl = a[p];
      rz = 1;
      while (dl > 0) {
        T[j].sum[dl % 10] += rz;
        rz *= 10;
        dl /= 10;
      }
      p++;
    }
    for (int j = N - 1; j >= 1; j--) {
      for (int x = 0; x < 10; x++) {
        T[j].sum[x] = T[j * 2].sum[x] + T[j * 2 + 1].sum[x];
      }
    }
  }
  void Push(int node, int tl, int tr) {
    memset(ch, 0, sizeof ch);
    for (int j = 0; j < 10; j++) {
      ch[T[node].nx[j]] += T[node].sum[j];
    }
    for (int j = 0; j < 10; j++) T[node].sum[j] = ch[j];
    if (tl != tr) {
      for (int j = 0; j < 10; j++) pi[j] = j;
      for (int j = 0; j < 10; j++) {
        pi[j] = T[node].nx[T[node * 2].nx[j]];
      }
      for (int j = 0; j < 10; j++) {
        T[node * 2].nx[j] = pi[j];
      }
      for (int j = 0; j < 10; j++) pi[j] = j;
      for (int j = 0; j < 10; j++) {
        pi[j] = T[node].nx[T[node * 2 + 1].nx[j]];
      }
      for (int j = 0; j < 10; j++) {
        T[node * 2 + 1].nx[j] = pi[j];
      }
    }
    for (int j = 0; j < 10; j++) T[node].nx[j] = j;
  }
  void Update(int node, int cl, int cr, int tl, int tr, int xu, int yu) {
    Push(node, cl, cr);
    if (cr < tl) return;
    if (cl > tr) return;
    if (cl > cr) return;
    if (cl >= tl and cr <= tr) {
      T[node].nx[xu] = yu;
      Push(node, cl, cr);
      return;
    }
    int md = (cl + cr) / 2;
    Update(node * 2, cl, md, tl, tr, xu, yu);
    Update(node * 2 + 1, md + 1, cr, tl, tr, xu, yu);
    for (int j = 0; j < 10; j++)
      T[node].sum[j] = T[node * 2].sum[j] + T[node * 2 + 1].sum[j];
  }
  long long Ask(int node, int cl, int cr, int tl, int tr) {
    Push(node, cl, cr);
    if (cr < tl) return 0;
    if (cl > tr) return 0;
    if (cl > cr) return 0;
    if (cl >= tl and cr <= tr) {
      long long rez = 0;
      for (int j = 0; j < 10; j++) {
        rez += T[node].sum[j] * j;
      }
      return rez;
    }
    int md = (cl + cr) / 2;
    return Ask(node * 2, cl, md, tl, tr) +
           Ask(node * 2 + 1, md + 1, cr, tl, tr);
  }
};
SegTree TR;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n, q;
  cin >> n >> q;
  long long k[n];
  for (int i = 0; i < n; i++) cin >> k[i];
  TR.Init(n, k);
  int ty;
  int l, r, x, y;
  for (int i = 0; i < q; i++) {
    cin >> ty;
    if (ty == 1) {
      cin >> l >> r >> x >> y;
      --l, --r;
      TR.Update(1, 0, TR.N - 1, l, r, x, y);
    } else {
      cin >> l >> r;
      --l, --r;
      cout << TR.Ask(1, 0, TR.N - 1, l, r) << "\n";
    }
  }
  return 0;
}