func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   int lz[N << 2][10];   long long sum[N << 2][10], tmp[10];   void push_up(int rt) {     for (int i = 0; i < 10; ++i) sum[rt][i] = 0;     for (int i = 0; i < 10; ++i) sum[rt][lz[(rt << 1)][i]] += sum[(rt << 1)][i];     for (int i = 0; i < 10; ++i)       sum[rt][lz[(rt << 1 | 1)][i]] += sum[(rt << 1 | 1)][i];   }   void build(int rt, int l, int r) {     for (int i = 0; i < 10; ++i) lz[rt][i] = i, sum[rt][i] = 0;     if (l == r) {       int t, tmp = 1;       scanf( %d , &t);       while (t) sum[rt][t % 10] += tmp, tmp *= 10, t /= 10;       return;     }     int m = (l + r) >> 1;     build((rt << 1), l, m);     build((rt << 1 | 1), m + 1, r);     push_up(rt);   }   void push_down(int rt) {     for (int i = 0; i < 10; ++i) lz[(rt << 1)][i] = lz[rt][lz[(rt << 1)][i]];     for (int i = 0; i < 10; ++i)       lz[(rt << 1 | 1)][i] = lz[rt][lz[(rt << 1 | 1)][i]];     memset(tmp, 0, sizeof(tmp));     for (int i = 0; i < 10; ++i) tmp[lz[rt][i]] += sum[rt][i];     for (int i = 0; i < 10; ++i) sum[rt][i] = tmp[i];     for (int i = 0; i < 10; ++i) lz[rt][i] = i;   }   void update(int rt, int l, int r, int ql, int qr, int x, int y) {     if (ql <= l && qr >= r) {       for (int i = 0; i < 10; ++i)         if (lz[rt][i] == x) lz[rt][i] = y;       return;     }     push_down(rt);     int m = (l + r) >> 1;     if (ql <= m) update((rt << 1), l, m, ql, qr, x, y);     if (qr > m) update((rt << 1 | 1), m + 1, r, ql, qr, x, y);     push_up(rt);   }   long long query(int rt, int l, int r, int ql, int qr) {     long long res = 0;     if (ql <= l && qr >= r) {       for (int i = 0; i < 10; ++i) res += sum[rt][i] * lz[rt][i];       return res;     }     push_down(rt);     int m = (l + r) >> 1;     if (ql <= m) res += query((rt << 1), l, m, ql, qr);     if (qr > m) res += query((rt << 1 | 1), m + 1, r, ql, qr);     return res;   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     build(1, 1, n);     while (q--) {       int op, l, r, x, y;       scanf( %d%d%d , &op, &l, &r);       if (op == 1) {         scanf( %d%d , &x, &y);         update(1, 1, n, l, r, x, y);       } else         printf( %I64d n , query(1, 1, n, l, r));     }     return 0;   }   