AlekuKebap is in his math class. While he tries to figure out why , his teacher was writing on the board a slightly more complicated problem. There are given queries and a list with elements equal with . Let be initially an empty set. The queries can be:
- (insert value in set )
- (erase the value from set , it is guaranteed that the value exists in set )
It is guaranteed that will never be empty after a query. After every query, the teacher asks Aleku the following question: can I arrange in list all elements from the set (not necessary in the order from the A) so that:
- Elements form will be put on distinct standings, the rest being occupied by elements equal to
- Let be a positive element from and the closest positive element from that is located to the left of , then the following condition must be respected: .
- Let be the first positive element from the left of , then .
If the answer to this question is yes, then find how many different configurations can be obtained. Because the answer can be very big, print the answer modulo . If the answer is no, print .
Task
Help AlekuKebap to answer correctly to all teacher’s questions to recive a 10 grade. His averave depends on this grade!!
Input
The first line contains two integers and .
The next lines contain the description of every query.
Output
Every line will contain the answer to every question from the questions.
Restrictions
- You have to print the answer modulo .
- All numbers that will be added in the set are .
- WARNING! If the answer for a query is no, print !!!
- WARNING! Alecu is not a kebap, he is a human being but this is his name. He is actually a captain... THE CAPTAIN.
# | Points | Restrictions |
---|---|---|
1 | 10 | |
2 | 10 | and all the values that will be at the same time in will be equal |
3 | 10 | and all the values that will be at the same time in will be different |
4 | 20 | |
5 | 15 | and all the values that will be at the same time in will be equal |
6 | 15 | and all the values that will be at the same time in will be different |
7 | 20 |
Example
stdin
9 8
0 3
0 3
0 2
1 2
0 1
0 1
0 1
1 3
1 1
stdout
6
6
3
6
12
6
-1
60
60