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;
int n, q;
vector<int> a;
bool read() {
  if (scanf("%d%d", &n, &q) < 2) {
    return 0;
  }
  a.resize(n);
  for (int i = 0; i < int(n); ++i) {
    scanf("%d", &a[i]);
  }
  return 1;
}
const int B = 10;
struct node {
  long long coef[B];
  int who[B];
  node() {
    memset(coef, 0, sizeof coef);
    reset_who();
  }
  node(long long x) : node() {
    long long pw = 1;
    while (x) {
      int dig = x % B;
      coef[dig] += pw;
      pw *= B;
      x /= B;
    }
  }
  void apply(int x, int y) {
    if (x == y) {
      return;
    }
    for (int i = 0; i < int(B); ++i) {
      if (who[i] == x) {
        who[i] = y;
      }
    }
  }
  void push(node& other) {
    static int dest[B];
    for (int i = 0; i < int(B); ++i) {
      dest[i] = who[other.who[i]];
    }
    memcpy(other.who, dest, sizeof dest);
  }
  void add(const node& other) {
    for (int i = 0; i < int(B); ++i) {
      coef[other.who[i]] += other.coef[i];
    }
  }
  long long sum() const {
    long long res = 0;
    for (int i = 0; i < int(B); ++i) {
      res += coef[i] * who[i];
    }
    return res;
  }
  void reset_who() {
    for (int i = 0; i < int(B); ++i) {
      who[i] = i;
    }
  }
  void reset_comps() {
    static long long ncoef[B];
    memset(ncoef, 0, sizeof ncoef);
    for (int i = 0; i < int(B); ++i) {
      ncoef[who[i]] += coef[i];
    }
    reset_who();
    memcpy(coef, ncoef, sizeof coef);
  }
  void print() const {
    for (int i = 0; i < int(B); ++i) {
      printf("%d: coef=%lld, who=%d\n", i, coef[i], who[i]);
    }
  }
};
struct SegmTree {
  vector<node> t;
  int sz;
  SegmTree() {}
  SegmTree(const vector<int>& a) {
    sz = 1;
    while (sz < ((int)(a).size())) sz *= 2;
    t.resize(sz * 2);
    for (int i = 0; i < int(((int)(a).size())); ++i) {
      t[sz + i] = node(a[i]);
    }
    for (int v = sz - 1; v > 0; --v) {
      recalc(v);
    }
  }
  void push(int v) {
    t[v].push(t[v * 2]);
    t[v].push(t[v * 2 + 1]);
    t[v].reset_comps();
  }
  void recalc(int v) {
    t[v] = node();
    t[v].add(t[v * 2]);
    t[v].add(t[v * 2 + 1]);
  }
  void change(int v, int tl, int tr, int l, int r, int x, int y) {
    l = max(l, tl);
    r = min(r, tr);
    if (l > r) {
      return;
    }
    if (l == tl && r == tr) {
      t[v].apply(x, y);
      return;
    }
    push(v);
    int tm = (tl + tr) >> 1;
    change(v * 2, tl, tm, l, r, x, y);
    change(v * 2 + 1, tm + 1, tr, l, r, x, y);
    recalc(v);
  }
  void change(int l, int r, int x, int y) { change(1, 0, sz - 1, l, r, x, y); }
  long long get(int v, int tl, int tr, int l, int r) {
    l = max(l, tl);
    r = min(r, tr);
    if (l > r) {
      return 0;
    }
    if (l == tl && r == tr) {
      return t[v].sum();
    }
    push(v);
    int tm = (tl + tr) >> 1;
    long long res = get(v * 2, tl, tm, l, r);
    res += get(v * 2 + 1, tm + 1, tr, l, r);
    recalc(v);
    return res;
  }
  long long get(int l, int r) { return get(1, 0, sz - 1, l, r); }
};
int do_replace(int num, int x, int y) {
  int nw = 0;
  int pw = 1;
  while (num) {
    int dig = num % 10;
    num /= 10;
    if (dig == x) {
      dig = y;
    }
    nw = pw * dig + nw;
    pw *= 10;
  }
  return nw;
}
namespace Brut {
vector<int> a;
long long get(int l, int r) {
  long long res = 0;
  for (int i = l; i <= r; ++i) {
    res += a[i];
  }
  return res;
}
void change(int l, int r, int x, int y) {
  for (int i = l; i <= r; ++i) {
    a[i] = do_replace(a[i], x, y);
  }
}
};  // namespace Brut
void solve() {
  SegmTree T(a);
  for (int it = 0; it < int(q); ++it) {
    int type;
    scanf("%d", &type);
    int l, r;
    scanf("%d%d", &l, &r);
    --l;
    --r;
    if (type == 1) {
      int x, y;
      scanf("%d%d", &x, &y);
      assert(y);
      T.change(l, r, x, y);
    } else if (type == 2) {
      printf("%lld\n", T.get(l, r));
    } else {
      assert(0);
    }
  }
}
int main() {
  while (read()) {
    solve();
  }
  return 0;
}