| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 17 | 0 | 0 | 0.000% |
Today, Esmaan decided to prove to the world that he is not ordinary. He went to take the exam to become a data structures master. But the first question of the exam stumped him. Help him solve the problem:
You have a sequence of integers $a_1, a_2, \ldots, a_n$. In addition, you have three empty sequences: $A$, $B$, and $C$.
You need to perform $q$ queries of the following type:
After each query, output $S$ modulo $998\,244\,353$.
The first line contains two integers $n$ and $q$ ($1 \le n, q \le 10^5$): the number of elements in the sequence and the number of queries.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^5$): the elements of the sequence.
Then follow $q$ lines, each containing a query in the format "$X$ $\mathit{val}$" ($X \in \{$A, B, C$\}$, $1 \le \mathit{val} \le n$).
After each query, output a line with a single integer: the current value of $S$ modulo $998\,244\,353$.
5 5 2 2 9 1 10 A 5 A 1 C 4 B 1 C 5
0 0 0 19 39
10 10 5 6 5 5 10 4 8 9 5 4 C 8 C 8 B 8 B 2 A 7 C 7 C 4 B 4 A 7 B 5
0 0 0 0 38 57 77 117 234 314