There are *n* servers in a laboratory, each of them can perform tasks. Each server has a unique id — integer from 1 to *n*.

It is known that during the day *q* tasks will come, the *i*-th of them is characterized with three integers: *t*<sub class="lower-index">*i*</sub> — the moment in seconds in which the task will come, *k*<sub class="lower-index">*i*</sub> — the number of servers needed to perform it, and *d*<sub class="lower-index">*i*</sub> — the time needed to perform this task in seconds. All *t*<sub class="lower-index">*i*</sub> are distinct.

To perform the *i*-th task you need *k*<sub class="lower-index">*i*</sub> servers which are unoccupied in the second *t*<sub class="lower-index">*i*</sub>. After the servers begin to perform the task, each of them will be busy over the next *d*<sub class="lower-index">*i*</sub> seconds. Thus, they will be busy in seconds *t*<sub class="lower-index">*i*</sub>, *t*<sub class="lower-index">*i*</sub> + 1, ..., *t*<sub class="lower-index">*i*</sub> + *d*<sub class="lower-index">*i*</sub> - 1. For performing the task, *k*<sub class="lower-index">*i*</sub> servers with the smallest ids will be chosen from all the unoccupied servers. If in the second *t*<sub class="lower-index">*i*</sub> there are not enough unoccupied servers, the task is ignored.

Write the program that determines which tasks will be performed and which will be ignored.
The first line contains two positive integers *n* and *q* (1 ≤ *n* ≤ 100, 1 ≤ *q* ≤ 10<sup class="upper-index">5</sup>) — the number of servers and the number of tasks. 

Next *q* lines contains three integers each, the *i*-th line contains integers *t*<sub class="lower-index">*i*</sub>, *k*<sub class="lower-index">*i*</sub> and *d*<sub class="lower-index">*i*</sub> (1 ≤ *t*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>, 1 ≤ *k*<sub class="lower-index">*i*</sub> ≤ *n*, 1 ≤ *d*<sub class="lower-index">*i*</sub> ≤ 1000) — the moment in seconds in which the *i*-th task will come, the number of servers needed to perform it, and the time needed to perform this task in seconds. The tasks are given in a chronological order and they will come in distinct seconds.
In the first example in the second 1 the first task will come, it will be performed on the servers with ids 1, 2 and 3 (the sum of the ids equals 6) during two seconds. In the second 2 the second task will come, it will be ignored, because only the server 4 will be unoccupied at that second. In the second 3 the third task will come. By this time, servers with the ids 1, 2 and 3 will be unoccupied again, so the third task will be done on all the servers with the ids 1, 2, 3 and 4 (the sum of the ids is 10).

In the second example in the second 3 the first task will come, it will be performed on the servers with ids 1 and 2 (the sum of the ids is 3) during three seconds. In the second 5 the second task will come, it will be performed on the server 3, because the first two servers will be busy performing the first task.
4 3
1 3 2
2 2 1
3 4 3
6
-1
10
3 2
3 2 3
5 1 2
3
3
8 6
1 3 20
4 2 1
6 5 5
10 1 1
15 3 6
21 8 8
6
9
30
-1
15
36
4 1
6 1 1
1
1 10
4 1 1
9 1 1
10 1 1
12 1 1
13 1 1
15 1 1
16 1 1
18 1 1
19 1 1
20 1 1
1
1
1
1
1
1
1
1
1
1
4 10
1 1 1
3 1 2
4 1 2
6 1 2
8 1 2
13 1 2
16 1 1
17 1 2
19 3 1
20 1 1
1
1
2
1
1
1
1
1
6
1
100 1
1000000 100 1000
5050
5 3
1 4 10
2 2 5
3 1 6
10
-1
5
4 5
1 2 3
2 1 3
3 1 2
4 3 3
5 4 1
3
3
4
-1
10
5 3
1 4 4
4 2 2
5 5 2
10
-1
15
10 4
1 5 20
2 5 200
100 6 20
101 1 100
15
40
-1
1
8 6
1 3 20
4 2 1
6 6 5
9 1 1
15 3 6
21 8 8
6
9
-1
4
15
36
5 4
1 1 4
2 4 4
5 2 20
11 5 2
1
14
-1
15
8 4
1 3 2
2 3 100
10 6 20
11 5 20
6
15
-1
21
5 3
1 3 4
4 3 4
6 4 1
6
-1
10
4 3
1 3 10
2 2 15
12 4 1
6
-1
10
n, q = map(int, input().split())
servers = [0] * n

for _ in range(q):
    ti, ki, di = map(int, input().split())
    assigned_servers = []

    for i in range(n):
        if servers[i] == 0:
            assigned_servers.append(i+1)
        
        if len(assigned_servers) == ki:
            break
    
    if len(assigned_servers) == ki:
        print(sum(assigned_servers))
        for server in assigned_servers:
            servers[server-1] = 1
    else:
        print(-1)
    
    for i in range(n):
        if servers[i] == 1 and ti + di - 1 <= i+1:
            servers[i] = 0