#P1774F1. Magician and Pigs (Easy Version)

    ID: 411 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 9 Uploaded By: Tags>brute forcedata structuresimplementation*2400

Magician and Pigs (Easy Version)

Description

This is the easy version of the problem. The only difference between the two versions is the constraint on nn and xx. You can make hacks only if both versions of the problem are solved.

Little09 has been interested in magic for a long time, and it's so lucky that he meets a magician! The magician will perform nn operations, each of them is one of the following three:

  • 1 x1\ x: Create a pig with xx Health Points.
  • 2 x2\ x: Reduce the Health Point of all living pigs by xx.
  • 33: Repeat all previous operations. Formally, assuming that this is the ii-th operation in the operation sequence, perform the first i1i-1 operations (including "Repeat" operations involved) in turn.

A pig will die when its Health Point is less than or equal to 00.

Little09 wants to know how many living pigs there are after all the operations. Please, print the answer modulo 998244353998\,244\,353.

The first line contains a single integer nn (1n21051\leq n\leq 2\cdot 10^5)  — the number of operations.

Each of the following nn lines contains an operation given in the form described in the problem statement. It's guaranteed that 1x21051\leq x\leq 2\cdot 10^5 in operations of the first two types.

Print a single integer  — the number of living pigs after all the operations, modulo 998244353998\,244\,353.

Input

The first line contains a single integer nn (1n21051\leq n\leq 2\cdot 10^5)  — the number of operations.

Each of the following nn lines contains an operation given in the form described in the problem statement. It's guaranteed that 1x21051\leq x\leq 2\cdot 10^5 in operations of the first two types.

Output

Print a single integer  — the number of living pigs after all the operations, modulo 998244353998\,244\,353.

Sample Input 1

4
1 8
2 3
3
3

Sample Output 1

2

Sample Input 2

6
1 5
1 6
2 2
3
1 4
3

Sample Output 2

5

Sample Input 3

12
2 1
1 15
1 9
3
1 12
2 2
1 13
3
2 1
1 9
1 8
3

Sample Output 3

17

Note

In the first example, the operations are equivalent to repeating four times: create a pig with 88 Health Points and then reduce the Health Points of all living pigs by 33. It is easy to find that there are two living pigs in the end with 22 and 55 Health Points.