thegrade

Time limit: 0.3s Memory limit: 512MB Input: Output:

AlekuKebap is in his math class. While he tries to figure out why 1+1=21+1=2, his teacher was writing on the board a slightly more complicated problem. There are given QQ queries and a list SS with PP elements equal with 00. Let AA be initially an empty set. The queries can be:

  • 0 x0 \ x (insert value xx in set AA)
  • 1 x1 \ x (erase the value xx from set AA, it is guaranteed that the value xx exists in set AA)

It is guaranteed that AA will never be empty after a query. After every query, the teacher asks Aleku the following question: can I arrange in list SS all elements from the set AA (not necessary in the order from the A) so that:

  • Elements form AA will be put on distinct standings, the rest being occupied by PP elements equal to 00
  • Let SiS_i be a positive element from SS and SjS_j the closest positive element from SS that is located to the left of SiS_i, then the following condition must be respected: ijSii-j \geq S_i.
  • Let ff be the first positive element from the left of SS, then fSff \geq S_f.

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 1 000 000 0071 \ 000 \ 000 \ 007 . If the answer is no, print 1-1.

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 QQ and PP.

The next QQ lines contain the description of every query.

Output

Every line will contain the answer to every question from the QQ questions.

Restrictions

  • You have to print the answer modulo 1 000 000 0071 \ 000 \ 000 \ 007.
  • All numbers that will be added in the set are 1 000 000\leq 1 \ 000 \ 000.
  • WARNING! If the answer for a query is no, print 1-1!!!
  • 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 Q22,P22Q \leq 22, P \leq 22
2 10 Q100 000,P3 000Q \leq 100 \ 000, P \leq 3 \ 000 and all the values that will be at the same time in AA will be equal
3 10 Q100 000,P3 000Q \leq 100 \ 000, P \leq 3 \ 000 and all the values that will be at the same time in AA will be different
4 20 Q100 000,P3000Q \leq 100 \ 000, P \leq 3000
5 15 Q100 000,P100 000Q \leq 100 \ 000, P \leq 100 \ 000 and all the values that will be at the same time in AA will be equal
6 15 Q100 000,P100 000Q \leq 100 \ 000, P \leq 100 \ 000 and all the values that will be at the same time in AA will be different
7 20 Q100 000,P100 000Q \leq 100 \ 000, P \leq 100 \ 000

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

Log in or sign up to be able to send submissions!