School correspondence#11064

School correspondence

1 second
128 megabytes
Very easy

Losyash decided to make education more accessible to Smeshariki and opened a school. Of course, as in any other school, this school has teachers (for example, Pin and Sovunya) and students (for example, Krosh and Hedgehog). And, of course, Losyash is the director. In total at school there are Smeshariki (teaching staff and students). For convenience, we enumerate them with positive integers from to .

For communication between students and teachers, a messenger was created that allows to write a message to any other user, but with some additional rules:

Please note that when the Director reads an unread message sent by a student, it is removed from the unread only for him (and not for teachers).

Losyash wants to optimize the learning process, so at some points in time he is interested in how many unread messages a particular user has.

You are given a sequence of events in the order in which they happened. For each event corresponding to Losyash's question, print the answer.

Input

The first line contains two integers and (1 \leq n, q \leq 2 \cdot 10^5) - the number of Smeshariks at school and the number of events, respectively.

The second line contains integers t_i (t_i \in \{0, 1, 2\}) - the roles of Smeshariki. If t_i = 0, then -th Smesharik is a director Losyash. If t_i = 1 is a teacher. Otherwise, it is a student. It is guaranteed that exactly one number among t_i equals .

The following (1 \leq i \leq q) lines describe the events. Event number can be one of three types:

  • "1 a_i b_i" - user a_i sent a message to user b_i (1 \leq a_i, b_i \leq n, a_i \neq b_i).

  • "2 a_i x_i" - user a_i read the message sent during event number x_i (1 \leq a_i \leq n, 1 \leq x_i < i).

  • "3 a_i" - print the number of unread messages for the user a_i (1 \leq a_i \leq n).

For all events of the second type, it is guaranteed that during event number x_i a message was sent that ended up in the user number a_i. And also that this message is still unread.

Output

For each event of the third type, print on a new line the number of unread messages for user a_i.

Examples

Example 1

Loading
Loading