#P6553. Strings of Monody

Strings of Monody

Background

LGD is a little dinosaur who likes Monody.

Based on the music of Monody, he built a model called the "String of Monody". For short, SoM (String of Monody).

Problem Description

A "String of Monody" is a string consisting only of 11, 44, and 55. In each operation, LsWn takes a substring with left endpoint ll and right endpoint rr (note that the first character has index 11, and the last character has index nn), and replaces it with a newly given substring. After the replacement, you need to answer 33 queries about the whole string:

  1. The number of 11's.
  2. The sum of all digits in the whole string.
  3. The product of all digits in the whole string.

All outputs should be taken modulo 99824353\color{black}998\color{red}24\color{black}353.

Input Format

The first line contains a string.
The second line contains an integer mm, meaning there are mm operations.
In the next mm lines, each line contains two integers l,rl, r, followed by a string of length rl+1r-l+1, meaning to change the substring (l,r)(l, r) into this string.

Output Format

Output mm lines. Each line contains 33 integers, representing the 33 queries after each modification.

114514
3
1 3 111  
3 4 44
4 4 5
4 13 20
3 15 64
3 16 80

Hint

Explanation for Sample 1:

After the first operation, the string becomes 111514. The number of 11's is 44, the sum is 1+1+1+5+1+4=131+1+1+5+1+4=13, and the product is $1\times 1\times 1\times 1\times 5\times 1\times 4=20$.
After the second operation, the string becomes 114414.
After the third operation, the string becomes 114514.


Let the initial string length be nn.

For 10%10\% of the testdata, n10n\le 10.
For 40%40\% of the testdata, n1000n\le 1000.
For all testdata, n106n\le 10^6, m103m\le 10^3, and 1rl+11031\le r-l+1\le 10^3.

Translated by ChatGPT 5