#K81292. Taco Text Editor Simulator

    ID: 35721 Type: Default 1000ms 256MiB

Taco Text Editor Simulator

Taco Text Editor Simulator

This problem simulates a simple text editor. The text editor consists of m lines (numbered from 1 to m) and supports a sequence of commands. There are three types of commands:

  • Type 1: 1 L text — Append the given text to the line L.
  • Type 2: 2 L — Clear the entire content of line L.
  • Type 3: 3 — Output the total number of characters currently present in the text editor.

The total number of characters is computed as \(\sum_{i=1}^{m} \text{length}(line_i)\). You are required to process a sequence of commands and print the result for every command of type 3.

Note: In the input, the first line contains two integers: m (the number of lines) and c (the number of commands). Each of the following c lines contains one command.

inputFormat

The first line of input contains two space-separated integers m and c — the number of lines in the editor and the number of commands, respectively. The next c lines each contain a command in one of the following formats:

  • 1 L text — Append text to line number L.
  • 2 L — Clear line number L.
  • 3 — Print the total number of characters in the text editor.

You can assume that text does not contain spaces.

outputFormat

For each command of type 3, output the current total number of characters in the text editor on a separate line.

## sample
3 7
1 1 Hello
1 2 World
3
2 1
3
1 3 !
3
10

5 6

</p>