Problem list
Log in
#coci00715 · COCI 2025/2026 Contest 4

Sladoled

Unrated 1.0 s 512 MB

In the ice cream city, $n$ ice cream stands have opened, but at the opening, none of the stands had any ice cream scoops for sale. In the next $q$ days, shipments of ice cream scoops will arrive at some stands. On each of the $q$ days, two integers $a$ and $b$ are given, meaning that stand $a$ received a shipment of ice cream scoops of flavor $b$ on that day. At each stand, it is also possible to make ice cream combinations. A combination can use the scoops that are available at that stand, where each scoop can be used an arbitrary number of times, and a combination consists of at least 1 ice cream scoop. The value of a combination is equal to the sum of the flavors of the scoops in that combination, and flavors can repeat. We are interested in combinations whose value is less than or equal to 50000 (combinations with higher values are too sweet). After each day, it is necessary to print how many different values of ice cream combinations can be made at the stand that received ice cream scoops on that day.

Input

The first line contains the natural numbers $n$ and $q$ ($1 \le n \le 100$, $1 \le q \le 10^{5}$), as described in the problem statement. Each of the next $q$ lines contains two numbers $a$ and $b$ ($1 \le a \le n$, $1 \le b \le 50000$), as described in the problem statement.

Output

Print $q$ lines with the answers to the queries described in the problem statement.

Constraints

Subtask 1 (16 points): $n = 1$, $q \le 20$

Subtask 2 (33 points): $q \le 100$

Subtask 5 (61 points): No additional constraints.

Example 1

Input
1 2
1 3
1 5
Output
16666
49996

Example 2

Input
2 4
2 35625
1 25139
1 37795
2 17791
Output
1
1
2
3

Explanation of the first sample test: After the first day, the values of ice cream combinations at the first stand that can be made are all multiples of 3 less than or equal to 50000. There are 16666 such combinations. After the second day, the only combination values that cannot be made are: 1, 2, 4, 7. All other combination values can be made, totaling 49996.

Source
COCI 2025/2026 Contest 4
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code