Under construction

Still being built. Things may change

Maggie's Homework

Time limit4sMemory limit1024 MB

Summary
Range-assign updates overwrite digits, and each query asks for the sum of all substring values in a range that do not start with 0, modulo 1e9+7.
Level

Medium7 of 10

Topics
Segment tree, Math, String
Solved
No attempts yet

Statement

Maggie Simpson has finally started first grade after thirty seasons. For handwriting practice, the teacher asked the children to write N digits from 0 to 9 in a row, in any order.

After hours of effort, Maggie finished the homework and ran off to play with her friends, leaving the paper on the desk. Lisa Simpson walked into the room and noticed the notebook.

Lisa quickly found the sum of all the digits Maggie wrote. Then Bart came in with a harder task: perform M operations on this digit string. Positions are numbered from 1 to N, left to right. There are two types of operations.

1 lil_i rir_i cic_i: replace every digit at positions lil_i through rir_i with the digit cic_i.

2 lil_i rir_i: compute the sum of all numbers whose decimal representations occur as substrings of the segment from position lil_i through rir_i. Each number is counted as many times as its representation occurs in the segment. Substrings that begin with '0' are not included in the sum. Output the answer modulo 109+710^9 + 7.

Input

The first line contains two integers N and M separated by a space, the number of digits and the number of Bart's operations (1≤N,M≤1000001 \le N, M \le 100000).

The second line contains N digits from 0 to 9, separated by spaces.

Each of the next M lines describes an operation. A line 1 lil_i rir_i cic_i is a first-type operation with 1≤li≤ri≤N1 \le l_i \le r_i \le N and 0≤ci≤90 \le c_i \le 9. A line 2 lil_i rir_i is a second-type operation with 1≤li≤ri≤N1 \le l_i \le r_i \le N.

Output

For each operation of the second type, print the answer modulo 109+710^9 + 7 on its own line. If there are no operations of the second type, print nothing.

Note

In the first sample, the answer to the first type-2 operation is 1+12+121+2+21+1=1581 + 12 + 121 + 2 + 21 + 1 = 158. The answer to the second is 2+20+203+0+3=2282 + 20 + 203 + 0 + 3 = 228. That sum has fewer terms because 03 is not a valid decimal representation of an integer.

Examples2

  1. Example 1

    Input
    4 3
    1 2 1 3
    2 1 3
    1 3 3 0
    2 2 4
    
    Expected output
    158
    228
    
  2. Example 2

    Input
    9 3
    1 1 1 1 1 1 1 1 1
    2 1 9
    1 1 9 9
    2 1 9
    
    Expected output
    137174205
    234567838